将参数从 cmd 行传递到 package.json
Passing a param from cmd line to package.json
"scripts": {
"start": "gulp",
...
},
我正在使用通过 npm start 运行的包。我想将参数传递给启动命令。
如何在命令行中传递参数?
npm start --myparam = hello
Alos,如何在我的 package.jspn 文件中访问它以传递给 gulp:
"scripts": {
"start": "gulp --myparam",
...
},
如果我对你的问题的理解正确,你正在尝试 运行 gulp --myparam=hello
使用 npm start
命令。
正确的做法是npm start -- --myparam=hello
。
注意命令中的--
。 --
之后的任何内容都将直接传递给启动命令 (gulp
)。
要求--
的原因是npm start
(和npm run
)也可以带参数;喜欢 -s
以静音 npm
.
的默认输出
"scripts": {
"start": "gulp",
...
},
我正在使用通过 npm start 运行的包。我想将参数传递给启动命令。
如何在命令行中传递参数?
npm start --myparam = hello
Alos,如何在我的 package.jspn 文件中访问它以传递给 gulp:
"scripts": {
"start": "gulp --myparam",
...
},
如果我对你的问题的理解正确,你正在尝试 运行 gulp --myparam=hello
使用 npm start
命令。
正确的做法是npm start -- --myparam=hello
。
注意命令中的--
。 --
之后的任何内容都将直接传递给启动命令 (gulp
)。
要求--
的原因是npm start
(和npm run
)也可以带参数;喜欢 -s
以静音 npm
.