0

Here is documentation about node config:

node myapp.js --NODE_CONFIG='{"Customer":{"dbConfig":{"host":"customerdb.prod"}}}'

BUt what if I run npm script? In this case all parameters will passed into npm not nodejs, am I wrong? How to pass --NODE_CONFIG from command line?

P.S. set up NODE_CONFIG as environment variable is not a solution in my case.

Cherry
  • 31,309
  • 66
  • 224
  • 364
  • this might help: https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script – gp. Apr 08 '19 at 14:46

1 Answers1

0

In order to inject args into an inner npm command, you need to use a -- delimiter.

package.json

"scripts": {
  "myscript": "node myapp.js"
}

And run this command to inject the NODE_CONFIG

npm run myscript -- --NODE_CONFIG='{"Customer":{"dbConfig":{"host":"customerdb.prod"}}}'
Amir Popovich
  • 29,350
  • 9
  • 53
  • 99