sublime build - nodejs - how to start and stop node app

孤者浪人 提交于 2020-01-02 05:57:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!