npm start, npm stop

2015-12-012 分钟阅读nodejsnpmtips

使用 npm 可以直接调用 package.json 里面 scripts 标签里定义的脚本。比如,Astinus 项目中,index.js 是入口JS,并且需要 ES6 支持,就可以这样:

    // package.json
    {
      "scripts": {
        “start": "node index --harmony"
      }
    }

然后直接运行

    npm start

即可。

那么怎么终止进程呢?

首先要在 index.js 里增加一句

    process.title = 'astinus';

声明该应用的标题是“astinus”,然后增加脚本:

    {
      "scripts": {
        "start": "node index --harmony",
        "stop": "killall SIGINT astinus"
      }
    }

之后就可以

    npm stop

参考:

觉得文章有帮助?

如果我的分享对你有所启发,欢迎通过赞助来支持我持续创作。

❤️ 赞助我

评论