Currently there is no (at least I don't know) cross platform way to tweak environment variables. For example,
"test": "NODE_ENV=test mocha -R spec"
will fail on windows, while some third party tools can require environment tweaking.
The proposal is to extend script field and give it an ability to receive config object like
"cmd": "mocha -R spec"
This is not npm's job. You can run custom Node scripts to set environment variables using process.env if you'd like, or use something that isn't environment variables (like JSON).
People do use environment variables, for example it's not nice to test connect.errorHandler() without NODE_ENV=test. Npm already adds ./node_modules/.bin to the PATH and runs shell commands. Without tweaking environment this functionality is just incomplete.
That's really a limitation of your testing environment and of the connect package. Again, not npm's job. You can write custom scripts to work around connect's limitations, e.g. in your tests modify process.env.
Point directly at `config/index.js` at package.json
Looks like just `config` can be problematic on some platforms.
This npm module helps:
cross-env solve this problem perfectly, hope helps.
@zixia I wish it would also solve problem of using environment variables in package.json scripts e.g.
"test": "istanbul --config=test/.istanbul.yml cover node_modules/mocha/bin/_mocha -- --check-leaks -t $MOCHA_TIMEOUT -b -R spec test/index.js"