问题
So my node build is like this
{
"cmd": ["node", "$file"],
"selector" : "source.js",
"path" : "/usr/local/bin"
}
It runs, but problem is once it runs, it never stop.
回答1:
You can use a reloader like node-dev for this kind of thing.
Replace node
with node-dev
(npm install -g node-dev
) and that's it so your build file looks like this:
{
"cmd": ["node-dev", "$file"],
"selector" : "source.js",
"path" : "/usr/local/bin"
}
I personally use node-dev, but you may also try node-supervisor or node-nodemon.
回答2:
for windows users, use "shell_cmd" instead of "cmd"
{
"shell_cmd": "node ${file}"
}
If you need to stop/cancel build, open "Tools | Cancel Build"
回答3:
Putting together all the answers in a step by step:
1) Install node-dev package:
npm install -g node-dev
2) Create a new Build on your Sublime Text
Tools > Build System > New Build System…
{
"cmd": ["node-dev", "$file"],
"selector" : "source.js",
"path" : "/usr/local/bin"
}
save the file as NodeJS.sublime-build.
3) Open your project, select your new node Build System, and Change your code and save.
来源:https://stackoverflow.com/questions/12127711/sublime-build-nodejs-how-to-start-and-stop-node-app