Open shfshanyue opened 3 years ago
如在npm script 中有以下命令:
npm script
{ "start": "serve" }
其中 serve 可通过 --port 指定端口号:
serve
--port
$ npm start -- --port 8080 # 而在 yarn 时无需传递参数 $ yarn start --port 8080
那为什么 npm 执行命令传递参数时,为何需要双横线
https://github.com/npm/npm/pull/5518 npm脚本执行时会开启一个shell,执行后面指定的脚本命令或文件, -- 是为了给后面shell脚本命令传递参数,类似node环境的process.argv的吧。
如在
npm script
中有以下命令:其中
serve
可通过--port
指定端口号:那为什么 npm 执行命令传递参数时,为何需要双横线