WARNING: NODE_ENV value of 'test ' did not match any deployment config file names

BlueWolf picture BlueWolf · Feb 19, 2019 · Viewed 16.9k times · Source

Receiving this warning on running a node.js app despite all testing suggesting everything fine.

I've included the below code in my app to fault find:

console.log('NODE_ENV: ' + config.util.getEnv('NODE_ENV')); console.log('NODE_CONFIG_DIR: ' + config.util.getEnv('NODE_CONFIG_DIR'));

And the output in terminal is:

NODE_ENV: test NODE_CONFIG_DIR: C:\Users\[username]\OneDrive - [Company Name]\Documents\projects\[project name]\server\config

Terminal Output

Terminal Output

Inside that folder (verified by copying and pasting the URI into explorer) are two files:

default.json test.json

Config folder contents

Config folder contents

That seems to be correct to me, I've checked the guidance and can't see anything out, checked google hits and the answers don't appear to relate. Any help would be greatly appreciated.

Answer

Santhosh John picture Santhosh John · Apr 10, 2020

Though the mentioned package in the accepted answer resolves the issue, it is good not to get more dependencies in your project's package.json when the same can be sorted with a simple tweak as below: -

In your package.json file by omitting the space before &&. This will detect the environment(s) correctly without extra space after the name.

enter image description here