Frustratingly, the Sublime Text editor doesn't set up a build system for JavaScript the way it does for Ruby and some other languages. Fortunately, it's an easy problem to fix. Assuming your JS interpreter is Node.js, these are the steps to set it up:

Leave a Reply

Your email address will not be published. Required fields are marked *

17 replies
  • Hippo says:

    Or you could simply use a Makefile. Sublime has support for make. 😉

  • Bad Andy says:

    This works a treat, mate! Exactly what I was looking for. Cheers!

  • Phil says:

    You have to save the file before it actually works, by the way…

  • George says:

    This works great, but for some reason ST is not recognizing the build and using it automatically with .js files. I have to manually click into the build menu and change the build system to “Javascript” for it to work. Do you know why Automatic is not recognizing it as valid for .js files?

  • George says:

    Nevermind, I actually figured it out. For “selector” you need to to use source.js instead of *.js. This fixed it at least on my machine.

  • Steve says:

    I had a quick question on this.

    I am using OSX, and have node.js installed. After setting the build system up I save the file and run it, but it gives me this as the output:

    [Errno 2] No such file or directory
    [cmd: [u’node’, u’/Users/XXX/test.js’, u’test’]]
    [dir: /Users/XXX]
    [path: /usr/bin:/bin:/usr/sbin:/sbin]

    I copied the build system data exactly as it appears above. Any advice?

  • Mai says:


    I know posted some time ago, but did you restart Sublime Text after you made the new build? Should work if you restart.

  • Branislav Dinic says:

    Thx, node was not working on automatic build!

  • Ron says:

    If you get Errno 2] No such file or directory
    then replace “node” with the path to node. ex: /usr/local/bin/node

  • Some people have errors because path is in other dir, for this peoples use this:
    “cmd”: [“/usr/local/bin/node”, “$file”, “$file_base_name”],
    “working_dir”: “${project_path:${folder}}”,
    “selector”: “*.js”

  • RJNY86 says:

    This worked for me

    “cmd”: [“node”, “$file”],
    “selector”: “source.js”

  • Hector Mota says:

    Thanks man it works for me as the original

  • Ana says:

    Thank you this one is working perfect for me.

  • David says:

    For me this was enough as well:
    “cmd”: [“node”, “$file”],
    “selector”: “source.js”

    And using source.js instead of *.js really makes automatic detection.

    Solution for “No such file or directory” if you’re using nvm:

    Consider using nvm alternative to avoid this problem.

  • Caim Astraea says:

    having some issues ? not working as i want it to …
    basically it needs a console.log for everything otherwise it won’t output
    something that would output when calling the function or variable directly .. without console.log or debug
    var a = ‘test’
    would output test.