简体   繁体   English

使用NPM构建命令启动时,以下脚本如何工作

[英]How does the following script works when started with a NPM build command

I have package.JSON file in which the script is mentioned as, 我有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"
  },

When npm is used as build with command, "run start build", In which order is script executed 当npm用作带有命令“运行开始构建”的构建时,按脚本顺序执行

Running npm run start build is going to run the "start": "http-server -p 8000", first and then "build": "tsc && webpack", . 运行npm run start build将首先运行"start": "http-server -p 8000",然后运行"build": "tsc && webpack", Although here since the start command is an http-server and will never return until cancelled, it should never get to call the next command. 尽管这里由于start命令是一个http服务器,并且直到被取消才返回,所以它永远不会调用下一个命令。

The NPM run command also called run-script allows to run arbitrary commands defined in the package.json file. NPM run命令(也称为run-script允许运行package.json文件中定义的任意命令。

ref: https://docs.npmjs.com/misc/scripts , https://docs.npmjs.com/cli/run-script 参考: https ://docs.npmjs.com/misc/scripts,https: //docs.npmjs.com/cli/run-script

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM