alert is not defined

Hi Folks:

I'm very new to webstorm 9.  I'm trying to use it to learn Javascript better.

I probably have something misconfigured but when I enter the following code:

var five = "GRAPE";

I end up with the following error in webstorm:

"C:\Program Files (x86)\JetBrains\WebStorm 9.0.1\bin\runnerw.exe" "C:\Program Files (x86)\nodejs\node.exe" MyFile.js

ReferenceError: alert is not defined
    at Object.<anonymous> (e:\Dropbox\WebstormProjects\untitled2\MyFile.js:5:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Process finished with exit code 8

I don't  really need to use any special javascript 'libraries' like jquery at the moment... just want to get the basics of  Javascript down first (I can get the code to run fine in Firebug, but I'd like to learn it on Webstorm to make the transition easier when I go more indepth in the future).

I tried searching the forum and ran "Invalidate caches / restart" a couple of times.
Thanks for any help...


Comment actions Permalink

Hi there,

As I see you are trying to execute your JavaScript file as nodejs file.

Thing is: alert() is a browser's window property and does not exist in nodejs which is for server side (simply speaking).

If you want to have it working you need to execute your JavaScript file in browser and not nodejs; for this you have to use different type of Run/Debug configuratiopn.

Comment actions Permalink

Hi Andriy:

Thank you for the link, it was very informative.

At this point my Javascript knowledge is very limited.  I didn't want to use node  (I just wanted a basic console window to enter and execute code till I learn much more about Javascript), but Webstorm wouldn't let me run any code after installing it because it wasn't 'configured' and I had to download and enter the paths to node.js.  

Maybe I'm missing it, but I'd like to have a console window that behaves like a browser window (that I can run alert() in instead of console.log() for instance.   I just haven't been able to figure out how to NOT use node.js in the configuration and instead run just basic javascript.  When I click on the help button on the configuration screen it just takes me to a help page for setting up node.js.

Are there any help pages/video on configuring Webstorm to use just basic javascript?

Thanks again for your help,



Please sign in to leave a comment.