Running Node.js in Atom

Running Node.js in Atom

Recently I've started writing Node.js and got to fiddle my way through configuring my Atom install to automatically run my Node.js code for me.

Installing Node.js

You can install Node.js using nvm (Node Version Manager) or you can download it from the official site.

I recommend using nvm to keep your version of Node.js up to date. To install the current stable version of Node.js on Ubuntu you can use the following command:

sudo apt-get install nodejs

Installing Atom

Atom is a text editor created by the people behind Github, you can download it from it's homepage:

If you're on Ubuntu you can install (using WebUpd8 PPA) like so:

sudo add-apt-repository ppa:webupd8/atom
sudo apt-get update
sudo apt-get install atom

With Node.js and Atom installed, we can configure Atom to run our Node.js for us!

Configuring Atom to run Node.js

Because I'm a lazy sod, I'd rather write my code in Atom, then run it in Atom. Alt-tabbing is sooo early-2000s.

So what we want to do is install the package atom-runner. To do this we need to open Atom and then go to: Edit -> Preferences -> Install -> Packages. Then we search for atom-runner, and install it.

Now we need to edit our config file for Atom, open ~/.atom/config.cson where ~ is your home directory. Now paste the below (starting with one indentation, as below):


If you're on Ubuntu, you need to add js:"nodejs". Ubuntu is the only OS (that I know of, at least!) that has a different default package name for Node.js.

Ready to go!

After completing the above you should now be reading to go! So let's open a blank js file and paste in console.log("I can run Node.js from within Atom!") and save the file. Now use Alt + R to run your file, the output should come out in a new tab like so:

Running Node.js in Atom

That's all for now, I'll be back soon with another post so stay tuned.. I really am feeling Japan for next time!