EACCES:Elastic Beanstalk 部署的权限被拒绝

Posted

技术标签:

【中文标题】EACCES:Elastic Beanstalk 部署的权限被拒绝【英文标题】:EACCES: permission denied with Elastic Beanstalk deployment 【发布时间】:2020-09-03 06:53:08 【问题描述】:

我正在尝试通过 eb create 部署我的 node.js 应用程序,但出现以下错误:

2020/05/17 02:15:37.303673 [ERROR] An error occurred during execution of command [app-deploy] - [Use NPM to install dependencies]. Stop running the command. Error: Command /bin/sh -c npm --production install failed with error exit status 1. Stderr:npm WARN deprecated buffer@4.9.1: This version of 'buffer' is out-of-date. You must update to v4.9.2 or newer
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
node-pre-gyp WARN Using needle for node-pre-gyp https download 
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.5.0 and node@12.16.2 (node-v72 ABI, glibc) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/var/app/staging/node_modules/canvas/build' 

我有一个.ebextensions/00_canvas.cfg,它有:

packages:
    yum:
        cairo: []
        cairo-devel: []
        libjpeg-turbo-devel: []
        giflib-devel: []
        libpng-devel: []

还有一个.ebextensions/01_permissions.cfg

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/00_npm_permission.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      chown -R nodejs:nodejs /tmp/.npm
      chown -R nodejs:nodejs /var/app/staging/node_modules/canvas

我错过了什么?

【问题讨论】:

【参考方案1】:

尝试将unsafe-perm=true 添加到.npmrc 文件中:https://***.com/a/63689721/1062614

【讨论】:

以上是关于EACCES:Elastic Beanstalk 部署的权限被拒绝的主要内容,如果未能解决你的问题,请参考以下文章

Elastic BeanStalk 节点 Js/Angular 部署问题

Elastic Beanstalk 上的 NightmareJS 和 Electron - 权限被拒绝

Amazon Elastic BeanStalk 错误:无法创建 AWS Elastic Beanstalk 应用程序版本

将 AMI 映像用于 Elastic Beanstalk

elastic-beanstalk http请求超时

在 AWS Elastic Beanstalk 和 EKS 上部署了一个 laravel 应用程序 相同的数据库 RDS 为啥在 Elastic Beanstalk 中获得快速响应