How to run node app with sublime text


Question

How would you run node app with sublime text? Like this, open the file app.js in sublime, go to menu->tools->build, and it just runs. Simple like that

1
9
12/23/2016 3:18:11 AM

Accepted Answer

To run nodejs on sublime text, install node package "node dev" then create a sublime text build, the code should look like this

{
  "cmd": ["node-dev", "$file"],
  "selector" : "source.js",
  "path" : "/usr/local/bin"
}

Now to run a nodejs app, go to menu->tools->build.

5
12/23/2016 3:15:21 AM

Cmd+Shift+P , search for "Nodejs::Default File Settings" ,it will open file "Node.js.sublime-settings". you'll see:

{
  // save before running commands
  "save_first": true,
  // if present, use this command instead of plain "node"
  // e.g. "/usr/bin/node" or "C:\bin\node.exe"
  "node_command": false,
  // Same for NPM command
  "npm_command": false,

  "expert_mode": false,

  "ouput_to_new_tab": false
}

modify

"node_command": false,

to

"node_command": "/usr/local/bin/node",

if the node path is not the same with above, find it and change to yours.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon