Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sublime Text 3: Build System - node.js. NPM module not executing

I'm trying to execute node-dev in a sublime text 3 build system. node-dev is in my path:

cmd node-dev diplay

Yet when I run this build script:

{
  "cmd": ["node-dev", "$file"],
  "selector": "*.js"
}

I get this error, which also shows that npm is in my path.

npm in path img

yet when I run with the same build script using node instead of node-dev it executes just fine.

I've also tried to include the "path" variable pointing at the node-dev bin folder, which didn't help at all.

Any help would be appreciated. Thanks.

like image 233
todd.pund Avatar asked Dec 30 '13 17:12

todd.pund


3 Answers

Following worked for me in Sublime Text 3 on Windows

  1. Tools -> Build System -> New Build System...
  2. Enter the below text in the new file
  3. Save the file as "nodejs.sublime-build"
{
  "shell_cmd": "node ${file}",
  "selector" : "source.js"
}

Prerequisite is to have node.js installed

like image 132
Wand Maker Avatar answered Nov 11 '22 22:11

Wand Maker


Sublime text docs:

https://www.sublimetext.com/docs/build_systems.html

shell

Optional. If true, cmd will be run through the shell (cmd.exe, bash…)

Try to add "shell : true

{
  "cmd": ["node-dev", "$file"],
  "selector": "source.js",
  "windows" : {
     "shell": true
  }
}
like image 17
Ilan Frumer Avatar answered Nov 11 '22 20:11

Ilan Frumer


The command is incorrect for Sublime Text 3 :)

This is one example of running node as build system:

{
    "shell_cmd": "taskkill /F /IM node.exe & node ${file}"
}

Please note that the array-version doesn't work like in Sublime Text 2.

like image 6
Timotei Avatar answered Nov 11 '22 21:11

Timotei