NODE_ENV is not recognised as an internal or external command

前端 未结 3 1212
無奈伤痛
無奈伤痛 2021-01-17 09:38

I am developing in node.js and wanted to take into account both production and development environment. I found out that setting NODE_ENV while running the node.js server do

3条回答
  •  花落未央
    2021-01-17 10:17

    I can suggest cross platform sollution. It's done with the help of the cross-env npm package. Your script section would look like this:

    "scripts": {
        "globals" : "npm i -g cross-env",
        "start": "cross-env NODE_ENV=development &  node ./bin/server",
        "qa2": "cross-env NODE_ENV=qa2 & node ./bin/server",
        "prod": "cross-env NODE_ENV=production & node ./bin/server"
      }
    

    So you run once:

    npm run globals // to install global dependencies
    

    Then you're free to use your scripts both on linux and windows(mac?).

提交回复
热议问题