Stop all processes depending on npm start…

99封情书 提交于 2019-12-31 03:30:39

问题


I am starting multiple npm tasks in parallel (using &, not just in sequence &&). Thus in package.json:

"start": "npm run watch-blog & npm run watch-data & npm run server",

And those sub-tasks are useful stuff to me like:

"watch-blog" : "watchy -w _posts/**/* -- touch _pages/blog.md",

Question: How can I all shut down all three tasks together?

I noticed CTRLC is only killing the last. (my watch-blog survives and keeps „touching“)

Closing the terminal window doesn't help. Only killall node does the job, but that's killing more than I would like to…


回答1:


Killing detached processes (that's the word…) will be a pain. One will have to look at pids, and more stuff coming your way. Not to mention cross-platform issues, if meant to work under windows...

Easier and working:

npm install concurrently --save

and thus

"start": "concurrently \"npm run watch-blog\" \"npm run watch-data\" \"npm run serve\"",

Tested (under Ubuntu 16.04, npm 5.6).



来源:https://stackoverflow.com/questions/49725593/stop-all-processes-depending-on-npm-start

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