Armen Sanoyan
Armen Sanoyan

Reputation: 2042

'NODE_ENV' is not recognized as an internal or external command

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! [email protected] 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"

Upvotes: 2

Views: 5381

Answers (2)

KornholioBeavis
KornholioBeavis

Reputation: 2442

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"
    }

Upvotes: -1

user2926055
user2926055

Reputation: 1991

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.

Upvotes: 4

Related Questions