无法在package.json中设置环境变量

时间:2019-01-05 04:28:57

标签: javascript express environment-variables package.json

我尝试了以下package.json / Express对:

1)

"config": {
   "PORT": "8000"
}

console.log(Object.keys(process.env).filter(key => key.includes("npm_package_config")))
// returns []

2)

"scripts": {
   "dev": "cross-env PORT=8000 concurrently \"npm run server\" \"npm run client\"",
}

console.log(process.env.PORT)
//returns undefined

concurrently命令用于启动和Express应用程序后端以及React前端。

0 个答案:

没有答案