How to set Environment Variable on NodeJS

###如何設定 NodeJs Environment Variable

解決方法:
可以直接在 command line 設定

set ENV_VARIABLE=9000 && npm start

可以在package.json 上設定
e.g.

  "scripts": {
    "start": "set PORT=9000 &&  yarn run swagger && nodemon --exec babel-node src/index.js",babel-node src/index.js",
    "test": "yarn jest --coverage",
    "lint": "eslint src",
    "swagger:edit": "swagger project edit",
    "swagger": "js-yaml ./api/swagger/swagger.yaml > ./src/swagger.json"
  },
Avatar
Chi Yau
Software Developer

Intererest to share knowledge / experience

comments powered by Disqus