为什么没有" npm运行"运行我的任意包脚本?

时间:2015-12-22 03:14:21

标签: node.js npm

我看了docs

npm run-script <command> [-- <args>...]
alias: npm run

Run arbitrary package scripts
This runs an arbitrary command from a package's "scripts" object. 
If no "command" is provided, it will list the available scripts.

好的,我添加了任意包脚本:

  "scripts": {
    "start": "node ./bin/www",
    "prestart": "gulp",
    "my_arbitrary_package_script": "node -e '2+2; process.exit(0);'"
  },

现在我运行它,但npmnode突然抛出错误ERR! missing script

$ npm run-script my_arbitrary_package_script
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run-script" "my_arbitrary_package_script"
npm ERR! node v5.3.0
npm ERR! npm  v3.3.12

npm ERR! missing script: my_arbitrary_package_script

该命令如何运作?为什么它不运行我的自定义脚本?

1 个答案:

答案 0 :(得分:0)

还要确保未将ignore-scripts全局设置为true

npm config set ignore-scripts false