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
参考错误:警报未定义
然后退出.在常规 html 页面上运行 javascript 时,我可以使用 alert
函数,所以我无法理解为什么会这样......这是我必须与 node.js 一起使用的单独模块吗?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屋!