简体   繁体   中英

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,

 "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

Running npm run start build is going to run the "start": "http-server -p 8000", first and then "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.

The NPM run command also called run-script allows to run arbitrary commands defined in the package.json file.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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