1

I am trying to run npm build on an old project I worked on months ago. It worked before after I ran

npm install -g win-node-env

Now I have formatted my machine but still getting this error

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

Here is my package.json:

"scripts": {
  "start": "NODE_ENV=development webpack --watch --progress --hide-modules --mode development --config webpack.config.js",
  "preview": "NODE_ENV=production webpack --watch --progress --hide-modules --mode production --config webpack.config.js",
  "build": "NODE_ENV=production webpack --mode production --config webpack.config.js"
}

This scrip worked before but now I cannot see what I am doing wrong. Any reasonable suggestion would be great!

FYI, I am using a Windows machine

RobC
  • 22,977
  • 20
  • 73
  • 80
Deejay
  • 907
  • 1
  • 6
  • 10
  • Does this answer your question? ["NODE\_ENV" is not recognized as an internal or external command, operable command or batch file](https://stackoverflow.com/questions/11928013/node-env-is-not-recognized-as-an-internal-or-external-command-operable-comman) – Amar Syla May 29 '20 at 08:26
  • https://create-react-app.dev/docs/adding-custom-environment-variables#windows-cmdexe – user0101 May 29 '20 at 08:31
  • None of these worked for me – Deejay May 30 '20 at 08:50
  • 1
    Consider installing [cross-env](https://github.com/kentcdodds/cross-env) in your project. Then add the `cross-env` keyword at the beginning of each of your npm scripts. For example, your `build` scripts would be redefined as: `"build": "cross-env NODE_ENV=production webpack --mode production --config webpack.config.js"` – RobC Jun 04 '20 at 14:43
  • Does this answer your question? [Node Environmental variable on Windows](https://stackoverflow.com/questions/44164458/node-environmental-variable-on-windows) – RobC Jun 04 '20 at 14:46

0 Answers0