在SharpElastic Beanstalk上安装Sharp

问题描述 投票:3回答:1

我对AWS相当陌生。我在Elastic Beanstalk上运行Node.JS应用程序,并且一切正常。但是,由于我需要进行一些图像处理,因此决定添加Puppeteer和Sharp。

但是,在AWS上的安装失败并且应用程序崩溃。日志显示以下内容:

  [email protected] install /tmp/deployment/application/node_modules/sharp
 (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

  ERR! sharp EACCES: permission denied, mkdir '/tmp/.npm/_libvips'
  info sharp Attempting to build from source via node-gyp but this may fail due to the above error
  info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
  gyp ERR! configure error 
  gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/sharp/build'
  gyp ERR! System Linux 4.14.97-74.72.amzn1.x86_64
  gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v10.15.1-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
  gyp ERR! cwd /tmp/deployment/application/node_modules/sharp
  gyp ERR! node -v v10.15.1
  gyp ERR! node-gyp -v v3.8.0
  gyp ERR! not ok 
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! [email protected] install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the [email protected] install script.
  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我真的不太熟悉Elastic Beanstalk,但这似乎是访问限制错误。经过一些搜索,我找到了可能的解决方案:将以下代码添加为.extension文件。

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

但是,这似乎没有任何作用。有人知道错误可能在哪里吗?还是我应该在哪里寻找解决方案?我通常不在家中使用这种东西,但是我不得不使用它一段时间。任何帮助和建议将不胜感激!

amazon-web-services npm-install amazon-elastic-beanstalk
1个回答
0
投票

这是AWS的权限问题。

要解决此问题,您必须执行以下步骤:

  1. 创建一个新文件.npmrc
  2. 添加以下unsafe-perm = true

这将允许写入文件。

© www.soinside.com 2019 - 2024. All rights reserved.