标签: tips

  • npm start, npm stop

    npm start, npm stop

    使用 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
    

    参考: