将命令行参数发送到npm脚本 - Sending command line arguments to npm script

问题:

The scripts portion of my package.json currently looks like this: 个人package.jsonscripts部分当前以下所示: node

"scripts": {
    "start": "node ./script.js server"
}

...which means I can run npm start to start the server. ...这意味着我能够运行npm start来启动服务器。 So far so good. 到如今为止还挺好。 npm

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? 这可能吗? json


解决方案:

参考一: https://stackoom.com/question/majh/将命令行参数发送到npm脚本
参考二: https://oldbug.net/q/majh/Sending-command-line-arguments-to-npm-script
相关文章
相关标签/搜索