Elastic Beanstalk - 访问 Web 应用程序时出现 502 错误,找不到 package.json



我刚刚将我的第一个 Web 应用程序部署到 Elastic Beanstalk 上,但是当我尝试访问它时,我收到"502 Bad Gateway"错误。在日志中,我看到此错误。

npm ERR! Please include the following file with any support request:
npm ERR!     /var/app/current/npm-debug.log
npm ERR! Linux 4.14.33-51.37.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.13.1-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.13.1-linux-x64/bin/npm" "start"
npm ERR! node v6.13.1
npm ERR! npm  v3.10.10
npm ERR! path /var/app/current/package.json
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open '/var/app/current/package.json'
npm ERR! enoent ENOENT: no such file or directory, open '/var/app/current/package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

我做了一些谷歌搜索,当用户不仅压缩文件夹的内容,而且压缩顶级文件夹本身时,似乎会出现此问题。但是,这不是我的情况 - 我在.zip文件的根目录中有package.json文件,但系统仍然找不到它。有没有人知道问题可能在哪里或如何找到根本原因?

谢谢

好的,刚刚找到了问题的核心 - 节点.js不是由EB自动启动的。为了修复它,我必须在压缩文件的根目录中创建文件夹".ebextensions",并在其中包含以下内容的文件nodecommand.config

中创建文件夹
option_settings:
- namespace: aws:elasticbeanstalk:container:nodejs
option_name: NodeCommand
value: "npm start"

相关内容

最新更新