I\'m trying to setup an environment for a Node.js app. but I\'m getting this error every time.
\"NODE_ENV\" is not recognized as an internal or extern
I had the same problem and on windows platform and i just ran the below command
npm install -g win-node-env
and everything works normally
for windows use &
in between command also. Like,
"scripts": {
"start": "SET NODE_ENV=development & nodemon app/app.js",
}
Changing your scripts to accommodate Windows is a royal pain. Trying to figure out the appropriate Windows translations and maintaining 2 sets of scripts is no way to live your life.
It's much easier to configure npm to use bash on Windows and your scripts will run as is.
Simply run npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"
. Make sure the path to the bash executable is correct for your machine. You'll likely need to start a new instance of the terminal for the change to take effect.
The screenshot below illustrates the benefit.
npm install --save-dev "cross-env"
module.cross-env NODE_ENV=development node foo.js
.
Then you can run the like npm run build
.