run javascript from sublime text

It’s very simple. We’ll use Node.js to compile and run javascript. This comes with Google’s V8 JS engine and its own set of rich libraries/ modules. Here goes:

1. Install Node.js using the conventional ‘.configure’, ‘make’, ‘make install’ trio. Put it in common location or add the installed dir to $PATH.

2. In sublime text, create a new build system:
‘Tools > Build System > New Build System…’. This creates a new file with build template.

3. Modify the file as below:

"cmd": ["node", "$file"]

4. Save it as


5. A new entry “JavaScript” (i.e. name given to the new build file) should come in Tools > Build System menu. Done. Just to test, create a ‘test.js’ with

console.log("Hello, World!);

in it. Build and run the file using Ctrl+B or menu item as you like.

PS: For Java, refer a similar post.


3 thoughts on “run javascript from sublime text

  1. Hi

    This is a great tip !

    Unfortunately when i build the hello world, my console just sais : [Finished in 0.1s] and no log.

    Do you have a clue ?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s