Mohammad Ali Shuvo
Mohammad Ali Shuvo

Reputation: 55

The term 'NODE_ENV=development' is not recognized as the name of a cmdlet, function, script file, or operable program

I want to set some env variable in my node app but when I run this command NODE_ENV=development x=23 nodemon.cmd server.jsenter image description here then it gives me that error NODE_ENV=development' is not recognized, I found some solution where it said that I have to run a npm package npm install -g win-node-env then it will work, but in my case, I got the same error. I am a windows user, any solution how to fix this.

Upvotes: 3

Views: 7356

Answers (1)

Jastria Rahmat
Jastria Rahmat

Reputation: 905

This may or may not relevant to your question, but as far as I know, windows powershell syntax does not assign variable that way.

to assign variable in windows, you can subtitute NODE_ENV=development with $NODE_ENV:development

As a workaround, and if you want to run it on any OS, use cross-env npm package.

npm install --save-dev cross-env

Now, it can run command such as:

cross-env NODE_ENV=development node server.js

Upvotes: 3

Related Questions