简体   繁体   中英

Passing a param from cmd line to package.json

"scripts": {
    "start": "gulp",
    ...
  },

I'm using a package that runs via npm start. I want to pass params to the start command.

How can I pass the param in the command line?

npm start --myparam = hello

Alos, how can I access this in my package.jspn file to pass through to gulp:

"scripts": {
    "start": "gulp --myparam",
    ...
  },

If I understand your question correctly, you are trying to run gulp --myparam=hello with the npm start command.

The correct way to do this is npm start -- --myparam=hello .

Notice the -- in the command. Anything after the -- will be passed directly to the start command ( gulp ).

The reason for requiring the -- is that npm start (and npm run ) can take parameters as well; like -s to silence the default output from npm .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM