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?
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?
Share Improve this question asked Jan 15, 2020 at 2:47 Jerry JosephJerry Joseph 1012 silver badges8 bronze badges3 Answers
Reset to default 14Have 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
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 mand in the package.json file thus:
cross-env NODE_ENV=development node my_script.js
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 mand line:
NODE_ENV=development node my_script.js