My configuration have MongoDB as the database. When running the command NODE_ENV=production npm run build, I am returned with an error which says The term ‘NODE_ENV=production’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Am I missing to setup anything on my machine?
[details=“System Information”]
-
Strapi Version: 3.5.4
-
Operating System: Windows 10
-
Database: MongoDB
-
Node Version: 14.16.1
-
NPM Version: 6.14.4
Just tried to set NODE_ENV=production and it still builds with development environment as you can see in the image attached.
![image](https://d38xoolefqxt5u.cloudfront.net/original/2X/b/b58c542c1a10bd518526416721a6f3716db7bc7d.png)
Tried these 2 commands too, and got no luck.
FYI, I’m using VS Code for development and building the application.
![image](https://d38xoolefqxt5u.cloudfront.net/original/2X/b/b2ad606309304275d860caeb4255b324d62bc655.png)
Thanks.
You can try with the cross-env option, sorry I don’t use Windows on a regular basis.
The best solution would probably be to add a package.json script like:
"build:prod": "cross-env NODE_ENV=production yarn build --clean",
npm install cross-env
Add the following in package.json
scripts section:
"production": "cross-env NODE_ENV=production npm run build"
Run the command
npm run production
1 Like
We should already have cross-env installed within Strapi itself so no need to install it directly