Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 466
BlueWolf Avatar asked Feb 19 '19 15:02

BlueWolf


Video Answer


1 Answers

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

like image 73
Santhosh John Avatar answered Sep 22 '22 08:09

Santhosh John