CityRay / Blog

Personal Blog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Node] 支援跨平台 NODE_ENV

CityRay opened this issue · comments

1. Installation

npm install --save-dev cross-env

2. Usage

{
  "scripts": {
    "prod": "cross-env Version=1.0.1.1 node prod.js"
  }
}

3. Get Value

在 prod.js 中就能抓取到 'Version' 值

console.log(process.env.Version);

Reference