pm2配置文件解析不了$HOME环境变量?
为了通用,pm2的test.config.js配置文件中含有$HOME变量: module.exports = { “apps”: [ { “name”: “Api”, “script”: “$HOME/Api/startApi.js”, “exec_mode”: “fork”, “err_file”: “$HOME/.pm2/logs/Api_err.log”, } ] };
结果运行的时候,pm2 start test.config.js 。发现无法展开$HOME变量,直接报错: script not found : /Users/xxx/yyy/$HOME/Api/startApi.js
3 回复
module.exports = {
apps: [
{
name: "chat",
script: "./src/server/index.js",
watch: true,
env: {
"PORT": 80,
"NODE_ENV": "dev",
},
env_prod: {
"PORT": 8002,
"NODE_ENV": "prod"
}
}
]
}
pm2 start ecosystem.config.js --env prod
既然是 JS,那么:
“script”: `${process.env.HOME}/Api/startApi.js`,
@JacksonTian 帅气,搞定。。