0
点赞
收藏
分享

微信扫一扫

Node.js:cross-env跨平台设置和使用环境变量


Run scripts that set and use environment variables across platforms

译文:运行跨平台设置和使用环境变量的脚本

安装

npm

使用 package.json

{
"scripts": {
"test": "cross-env NODE_ENV=production node test.js",
},
"devDependencies": {
"cross-env": "^7.0.3",
},
}

示例

# 直接运行,NODE_ENV是undefined
$ node test.js
undefined

# 运行脚本前设置环境变量
$ npx cross-env NODE_ENV=production node test.js
production


# 使用scripts
$ npm run test

> test
> cross-env NODE_ENV=production node


举报

相关推荐

0 条评论