我有package.JSON文件,其中提到了脚本,
"scripts": {
"typings": "typings install",
"build": "tsc && webpack",
"watch": "npm-run-all -p -r -l tsc-watch webpack-watch",
"tsc-watch": "tsc -w",
"webpack-watch": "webpack -w",
"clean": "rm -rf built",
"minify": "webpack --optimize-minimize --optimize-dedupe",
"start": "http-server -p 8000",
"pretest": "tsc -p tests",
"test": "mocha test/tests",
"foo": "mocha test/tests"
},
当npm用作带命令的构建时,“run start build”,脚本执行顺序
答案 0 :(得分:1)
正在运行npm run start build
将首先运行"start": "http-server -p 8000",
,然后运行"build": "tsc && webpack",
。虽然这里的 start 命令是一个http服务器,并且在取消之前永远不会返回,但它永远不会调用下一个命令。
NPM run
命令也称为run-script
,允许运行package.json文件中定义的任意命令。
参考:https://docs.npmjs.com/misc/scripts,https://docs.npmjs.com/cli/run-script