Plain JavaScript (hello world) developmnent in WS?
Hello all,
I've just installed WS with the objective of developing a simple DOM manipulation JavaScript file. If I understood correctly, WS supports plain JS, but from all the search I've made here (and outside) this forum, I've just found how to set up WS to work with Node.js.
So, my beginner question is as simple as this: how can I configure/set up WS to run a simple hello world JavaScript example?
<script>
alert( 'Hello, world!' );
</script>
The error I'm getting is (I'm on Windows 7):
"C:\Program Files\JetBrains\WebStorm 2017.3.2\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" C:\Users\Joao\WebstormProjects\xml_insert_html\insert.js
C:\Users\Joao\WebstormProjects\xml_insert_html\insert.js:2
alert( 'Hello, world!' );
^
ReferenceError: alert is not defined
at Object.<anonymous> (C:\Users\Joao\WebstormProjects\xml_insert_html\insert.js:2:5)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
Process finished with exit code 1
Please sign in to leave a comment.
What is 'plain js'?
You are running your .js file as Node.js application (node insert.js), and alert() is not defined in Node context, it's only defined when running in browser.
You need to create an .html file and link your javascript to it via <script scr="insert.js"> tag, then use either Run or Debug in .html file right-click menu to run your application
Thank you Elena, that was exactly what I was looking for.