Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NODE_ENV is not recognized as an internal or external command. #2

Open
LVSSandeepKumar opened this issue Jul 23, 2024 · 2 comments
Open

Comments

@LVSSandeepKumar
Copy link

When I added NODE_ENV in build and start commands in package.json as you suggested in the last module,
"scripts": { "dev": "NODE_ENV=development nodemon backend/server.js", "start": "NODE_ENV=production node backend/server.js", "build": "npm install && npm install --prefix frontend && npm run build --prefix frontend" },

I faced this error...

` npm run start

[email protected] start
NODE_ENV=production node backend/server.js

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

@LVSSandeepKumar
Copy link
Author

SOLUTION :-

The error occurs because Windows doesn't support setting environment variables in the same way as Unix-based systems. To make this work cross-platform, you can use the cross-env package, which allows you to set environment variables across different operating systems in a consistent way.

Steps to Fix:

1. Install cross-env
npm install cross-env

2.Update the start & dev script in your package.json:
"scripts": { "start": "cross-env NODE_ENV=production node backend/server.js", "dev": "cross-env NODE_ENV=development nodemon backend/server.js" }

3. Try npm run start in your terminal
npm run start

@Sitholezw
Copy link

ok the above solution works just make sure you update both Json.packages and by both I mean the internal and the external package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants