2

I have an app which is working perfectly on linux but when I execute it on windows I get this error.

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

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

npm
 ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aaa@1.0.0 webpack-watch: `NODE_ENV='debug' webpack --progress -d -colors --watch`
npm ERR! Exit status 1
npm ERR!

I have tried this in cmd.

SET NODE_ENV=debug

which I found here “NODE_ENV” is not recognized as an internal or external command

And here is snippet of code package.json where I guess is my mistake.

"webpack-watch": "NODE_ENV='debug' webpack --progress -d --colors --watch",
"server-watch": "NODE_ENV='debug' nodemon backend/server.js"
Community
  • 1
  • 1
Armen Sanoyan
  • 1,898
  • 2
  • 19
  • 32
  • Possible duplicate of ["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/40967643#40967643) – laggingreflex Jul 02 '19 at 07:07

2 Answers2

4

Windows doesn't understand the syntax var=value cmd1 arg1. You need to adapt the NPM run tasks to use Windows' syntax:

"webpack-watch-win": "set NODE_ENV=debug & webpack ..."
"server-watch-win": "set NODE_ENV=debug & nodemon ..."

....but there are probably more errors you will hit downstream. This should at least get you past the environment variable declaration, though. Node is strongly rooted in *nix shells, not cmd.exe.

user2926055
  • 1,963
  • 11
  • 10
  • Now I do't get any errors seems problem is solved, but it doesn't run watch and server which is bed. So I can't execute my app – Armen Sanoyan Apr 07 '17 at 18:34
  • I guess the problem is that this scripts doesn't execute the commands. Are they just setting up? – Armen Sanoyan Apr 07 '17 at 19:47
  • The problem is that you're running npm tools (nodemon, webpack) that have issues running under Windows for a whole variety of the most random reasons you could imagine. Try googling for "webpack windows" and "nodemon windows". – user2926055 Apr 07 '17 at 20:20
-1

Setup your NODE_ENV with export. So in your package.json add in your scripts block

    "scripts":{
        "webpack-watch": "export NODE_ENV='debug' && webpack --progress -d --colors --watch",
        "server-watch": "export NODE_ENV='debug' && nodemon backend/server.js"
    }
KornholioBeavis
  • 2,402
  • 2
  • 19
  • 26