Monday 13 March 2017

Setting up process.env variable from package json script

I want to set process.env.ENV as TEST or null using a script from package.json but below command is not working via package.json (it works when I run it directly on cmd.).

script { "start": "cross-env ENV=null && node app.js", "test": "cross-env ENV=TEST && istanbul cover mocha test" }

I am using corss-env to use a common syntax for setting up env variable for Windows and Linux.

Running set ENV=TEST or set ENV=null before npm start or npm test work fine.



via komal.mehta

No comments:

Post a Comment