问题:
The scripts
portion of my package.json
currently looks like this: 我的package.json
的scripts
部分当前如下所示:
"scripts": {
"start": "node ./script.js server"
}
...which means I can run npm start
to start the server. ...这意味着我可以运行npm start
来启动服务器。 So far so good. 到现在为止还挺好。
However, I would like to be able to run something like npm start 8080
and have the argument(s) passed to script.js
(eg npm start 8080
=> node ./script.js server 8080
). 但是,我希望能够运行npm start 8080
类的东西,并将参数传递给script.js
(例如npm start 8080
=> node ./script.js server 8080
)。 Is this possible? 这可能吗?
解决方案:
参考一: https://stackoom.com/question/majh/将命令行参数发送到npm脚本参考二: https://oldbug.net/q/majh/Sending-command-line-arguments-to-npm-script
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4263717