Jerry Joseph
Jerry Joseph

Reputation: 101

NODE_ENV' is not recognized as an internal or external command, operable program or batch file

I am learning NODE js and i have a server file that includes NODE_env as port configuration , the code works on a MAC but throws up an error on my windows. How do i solve this?

Upvotes: 0

Views: 9723

Answers (3)

Austin
Austin

Reputation: 414

If you run into this problem in 2021, install cross-env as a dev dependency by running npm i -D cross-env.

Then, modify your command in the package.json file thus: cross-env NODE_ENV=development node my_script.js

Upvotes: 2

Akshay Gaikwad
Akshay Gaikwad

Reputation: 161

Have you tried installing it globally or include it in your project's or your library's optional dependencies?

if not, try this:

install globally: npm install -g win-node-env

Or you may include it in your project's or your library's optional dependencies: npm install --save-optional win-node-env

refer below link for more information npmjs win-node-env

Upvotes: 14

Victor P
Victor P

Reputation: 1612

Are you asking how to set NODE_ENV in windows? You can set it as a user or machine environment variable. You can also set it when you call the script in the command line:

NODE_ENV=development node my_script.js

Upvotes: 0

Related Questions