简体   繁体   English

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

[英]Elastic Beanstalk - 502 error when accesing the webapplication, package.json not found

I just deployed my first web app to the Elastic Beanstalk, but when I try to access it, I get the "502 Bad Gateway" error. 我刚刚将我的第一个Web应用程序部署到Elastic Beanstalk,但是当我尝试访问它时,出现“ 502 Bad Gateway”错误。 In logs, I see this error. 在日志中,我看到此错误。

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 

I did some googling and it seems that this issue occurs when the users zips not only the content of the folder, but also the top-level folder itself. 我做了一些谷歌搜索,当用户不仅压缩文件夹的内容,而且压缩顶级文件夹本身时,似乎也会出现此问题。 However, this is not my case - I have package.json file in the root of my .zip file, but the system still cannot find it. 但是,这不是我的情况-我的.zip文件的根目录中有package.json文件,但系统仍然找不到它。 Does anyone have an idea where could be the problem or how to find the root cause? 有谁知道哪里可能是问题或如何找到根本原因?

Thank you 谢谢

OK, just found the core of the problem - the node.js wasnt started automatically by EB. 好的,只是找到了问题的核心-EB并没有自动启动node.js。 To fix it, I had to create folder ".ebextensions" in the root of the zipped file and in it a file nodecommand.config with the following content 要修复它,我必须在压缩文件的根目录中创建文件夹“ .ebextensions”,并在其中创建一个具有以下内容的文件nodecommand.config

option_settings:
  - namespace: aws:elasticbeanstalk:container:nodejs
    option_name: NodeCommand
    value: "npm start"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM