How do I make a Javascript file and run it?


#1

How do I make a JavaScript file and run it? I know I might need a package to run the code or might not be able to. I’m completely new to Atom and know a decent amount of JavaScript.


#2

Hi, you don’t need make a JavaScript to run it. Simply, you can run the JavaScript, that the script don’t contain any DOM, using node foo.js.

> node foo.js

In an other way, you can write a html file and link the JavaScript that you want to run, then use a browser to run.

May it could help you.


#3

If you want to run a file you’re currently developing via Node, you might use the build package (Disclaimer: I am the author).

You could configure it using a config file like this:

{
  "cmd": "node",
  "args": [ "{FILE_ACTIVE}" ]
}

Now, everytime you press ctrl-alt-b (Windows/Linux) or cmd-alt-b (OS X) it will run node with the current active file as argument (e.g. node main.js if you were editing main.js).