Reputation: 101
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
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
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
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