Elastic Beanstalk - 访问webapplication时出错502,找不到package.json

时间:2018-06-18 12:56:34

标签: node.js amazon-web-services elastic-beanstalk

我刚刚将我的第一个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文件,但系统仍无法找到它。有没有人知道哪里可能是问题或如何找到根本原因?

谢谢

1 个答案:

答案 0 :(得分:0)

好的,刚刚找到了问题的核心--End.js并没有自动启动。要修复它,我必须在压缩文件的根目录中创建文件夹“.ebextensions”,并在其中创建一个带有以下内容的文件nodecommand.config

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