我尝试在AWS Elastic Beanstalk上使用AWS CodeBuild启动node.js项目。我将我的env变量放在软件配置下的Elastic Beanstalk配置中。之后我将项目部署到Elastic Beanstalk,我的server.js没有env变量。
我在server.js的顶部实现了console.log(process.env),但是我没有填充Elastic Beanstalk配置的env变量。我访问了Elastic Beanstalk日志。
我的日志也告诉我:
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
npm ERR! Linux 4.9.43-17.39.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.11.1-linux-
x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.11.1-linux-
x64/bin/npm" "run" "start"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! xxxxxxx start: `NODE_ENV=production node server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the xxxxxxx start script 'NODE_ENV=production node server'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the xxxxxxx package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! NODE_ENV=production node server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs xxxxxxx
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls mapify-ssr
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log