Node.js警报导致崩溃 [英] Node.js Alert Causes Crash
问题描述
我正在尝试创建一个node.js应用,并且
I'm trying to create a node.js app and
alert('Sample Alert');
导致我的程序崩溃.节点说
is causing my program to crash. Node says
ReferenceError:未定义警报
ReferenceError: alert is not defined
,然后退出.在常规的html页面上运行javascript时,可以使用alert
函数,所以我不知所措,这是为什么...这是我必须与node.js一起使用的单独模块吗?
and then quits. I can use the alert
function when running javascript on a regular html page, so I'm at a loss to understand why this is... Is this a separate module that I have to use with node.js?
推荐答案
alert()
函数是浏览器window
对象的属性.它实际上不是JavaScript的一部分;它只是该环境中的JavaScript代码可用的工具.
The alert()
function is a property of browser window
objects. It is not really part of JavaScript; it's just a facility available to JavaScript code in that environment.
尝试console.log("Hello World");
这篇关于Node.js警报导致崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!