AWS EB 部署问题

Posted

技术标签:

【中文标题】AWS EB 部署问题【英文标题】:AWS EB deployment issue 【发布时间】:2018-05-09 12:48:45 【问题描述】:

我正在尝试将 Node.js 应用程序部署到 Elastic Beanstalk。该应用程序在本地正常运行。但是,当我尝试部署时,出现错误:

Failed to run npm install. Snapshot logs for more details.

以下是 EB 日志的屏幕截图以了解更多详细信息:

错误日志(我发现权限被拒绝很有趣——这意味着什么?):

/var/log/eb-activity.log
-------------------------------------
  npm ERR! path /tmp/.npm/node-linux-x64
  npm ERR! code EACCES
  npm ERR! errno -13
  npm ERR! syscall mkdir

  npm ERR! Error: EACCES: permission denied, mkdir '/tmp/.npm/node-linux-x64'
  npm ERR!     at Error (native)
  npm ERR!   Error: EACCES: permission denied, mkdir '/tmp/.npm/node-linux-x64'
  npm ERR!     at Error (native)
  npm ERR!   errno: -13,
  npm ERR!   code: 'EACCES',
  npm ERR!   syscall: 'mkdir',
  npm ERR!   path: '/tmp/.npm/node-linux-x64',
  npm ERR!   parent: 'node' 
  npm ERR! 
  npm ERR! Please try running this command again as root/Administrator.
  npm ERR! Linux 4.9.58-18.55.amzn1.x86_64
  npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.11.5-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.11.5-linux-x64/bin/npm" "install" "--no-save" "node-linux-x64@9.2.0"
  npm ERR! node v6.11.5
  npm ERR! npm  v3.10.10
  npm ERR! path npm-debug.log.487421323
  npm ERR! code EACCES
  npm ERR! errno -13
  npm ERR! syscall open

  npm ERR! Error: EACCES: permission denied, open 'npm-debug.log.487421323'
  npm ERR!     at Error (native)
  npm ERR!   Error: EACCES: permission denied, open 'npm-debug.log.487421323'
  npm ERR!     at Error (native)
  npm ERR!   errno: -13,
  npm ERR!   code: 'EACCES',
  npm ERR!   syscall: 'open',
  npm ERR!   path: 'npm-debug.log.487421323' 
  npm ERR! 
  npm ERR! Please try running this command again as root/Administrator.

  npm ERR! Please include the following file with any support request:
  npm ERR!     /tmp/deployment/application/node_modules/node/npm-debug.log
  module.js:471
      throw err;
      ^

  Error: Cannot find module 'node-linux-x64/package.json'
      at Function.Module._resolveFilename (module.js:469:15)
      at Function.resolve (internal/module.js:27:19)
      at ChildProcess.<anonymous> (/tmp/deployment/application/node_modules/node-bin-setup/index.js:18:27)
      at emitTwo (events.js:106:13)
      at ChildProcess.emit (events.js:191:7)
      at maybeClose (internal/child_process.js:920:16)
      at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)

  npm ERR! Linux 4.9.58-18.55.amzn1.x86_64
  npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.11.5-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.11.5-linux-x64/bin/npm" "--production" "rebuild"
  npm ERR! node v6.11.5
  npm ERR! npm  v3.10.10
  npm ERR! code ELIFECYCLE
  npm ERR! node@9.2.0 preinstall: `node installArchSpecificPackage`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the node@9.2.0 preinstall script 'node installArchSpecificPackage'.
  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 node package,
  npm ERR! not with npm itself.
  npm ERR! Tell the author that this fails on your system:
  npm ERR!     node installArchSpecificPackage
  npm ERR! You can get information on how to open an issue for this project with:
  npm ERR!     npm bugs node
  npm ERR! Or if that isn't available, you can get their info via:
  npm ERR!     npm owner ls node
  npm ERR! There is likely additional logging output above.

包.json:


  "name": "MyProject",
  "version": "0.0.1",
  "private": true,
  "dependencies": 
    "body-parser": "latest",
    "express": "latest",
    "node": "latest",
    "nodemailer": "latest"
  ,
  "scripts": 
    "start": "node app.js"
  

为什么会这样?

编辑:按要求添加了 package.json 和错误日志。

【问题讨论】:

那么日志文件是怎么说的? 请发布您的package.json,至少是脚本部分 用 log 和 package.json 编辑了我的帖子 有谁知道怎么回事? 【参考方案1】:

在没有信息的情况下,这里有一些猜测:

您正在手动压缩和上传您的应用程序。 Use the CLI tools,由于某种原因,eb deploy 总是更流畅 您的实例非常小,需要升级到具有足够内存来处理依赖项的实例

如果这些没有帮助,请发布您的package.json。或者,只需使用Up,它比 Beanstalk 容易得多。

【讨论】:

您所说的这些 CLI 工具是什么?我只看到了在 EB 部署过程中手动上传应用程序的选项。 这是一个使用 EB CLI 和 Node docs.aws.amazon.com/elasticbeanstalk/latest/dg/… 的教程 我尝试使用 CLI,但它似乎仍然无法正常工作。我认为问题主要在于 EACCS 权限被拒绝。

以上是关于AWS EB 部署问题的主要内容,如果未能解决你的问题,请参考以下文章

使用 AWS CodeBuild 和 EB CLI 部署到 AWS Elastic Beanstalk

AWS EB Deploy 在部署后显示缺少 Dockerrun.aws.json

我在 aws 中使用“eb deploy”进行部署,但出现以下错误

AWS EB 部署节点应用程序:无法运行 npm install

Django 部署到 AWS EB 显示 500 内部服务器错误

在 ec2 实例中部署 eb 后,ruby 应用程序 aws 数据丢失