我尝试了以下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前端。