Node.js Alert Causes Crash

Viewed 58394

I'm trying to create a node.js app and

alert('Sample Alert');

is causing my program to crash. Node says

ReferenceError: alert is not defined

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?

7 Answers

alert function is for browsers. means front end..in nodejs for printing in cmd or bash you should use this one..

console.log("Sample alert");

you can print any variable or constant here... for printing variables just remove quotes

The alert() property is only allowed by browsers, not JavaScript.

I don't see where it is documented but I have been using global.alert() in my react-native code. I am using it for debugging purposes because I am running an Appium test so I don't have access to the console.log() output.

Related