將命令行參數發送到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
相關文章
相關標籤/搜索