Anubhav Dhawan Anubhav Dhawan - 1 year ago 154
Node.js Question

How to get environment variable in npm script?

I am trying to access an enviroment variable in the npm script itself like so:

"scripts": {
"test": "istanbul cover node_modules/.bin/_mocha --root ../SERVER/routes -- --recursive"

And start this script like so:

SERVER=somewhere npm test

How can I get the resolved value of
variable in the npm script in the package.json itself?

Answer Source

Will using $SERVER work for you?

"scripts": { "test": "istanbul cover node_modules/.bin/_mocha --root ../$SERVER/routes -- --recursive" }

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download