Nodejs Error: "NODE_ENV" is not recognized as an internal or external command

Dung Do Tien Jun 04 2021 258

I'm a beginner in Nodejs, I'm trying to setup an environment for a Node.js app. But I got an error:

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

I installed package win-node-env by using the command:

npm install -g win-node-env

I'm using Windows and also tried set NODE_ENV=development but it's still not working.

How can I resolve it?

Have 2 answer(s) found.
  • J

    Jair Rojas Garcia Jun 04 2021

    It sounds like your error comes from an attempt to run something like this (which works in Linux)

     NODE_ENV=development node index.js

    the equivalent in Windows would be

     SET NODE_ENV=development
    node foo.js

    running in the same command shell. You mentioned set NODE_ENV did not work, but wasn't clear how/when you executed it.

    I hope it works for you!

  • R

    Raja T Jun 04 2021

    You can try with windows you can use & in between commands also. Like,

    "scripts": {
        "start": "SET NODE_ENV=development & nodemon app/app.js",
    }

    And it works for me.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close