gpt4 book ai didi

node.js - 在elasticbeanstalk上安装npm canvas - npm安装错误

转载 作者:太空宇宙 更新时间:2023-11-03 22:54:36 26 4
gpt4 key购买 nike

我正在尝试通过 Elasticbeanstalk 部署在 EC2 上运行的 Node.js 服务器。我遇到的问题是在重建 canvas npm 模块期间。命令“canvas@1.1.6 install: node-gyp重建”失败如下:

> canvas@1.1.6 install /tmp/deployment/application/node_modules/canvas
> node-gyp rebuild

gyp ERR! clean error
gyp ERR! stack Error: EACCES, unlink 'build'
gyp ERR! System Linux 3.10.35-43.137.amzn1.x86_64
gyp ERR! command "node" "/opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/deployment/application/node_modules/canvas
gyp ERR! node -v v0.10.26
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok

npm ERR! canvas@1.1.6 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@1.1.6 install script.
npm ERR! This is most likely a problem with the canvas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls canvas
npm ERR! There is likely additional logging output above.

问题似乎是 npm install canvas 命令没有以适当的权限运行。如果我手动 ssh 进入服务器并运行“sudo npm install canvas”,一切正常。这告诉我所有适当的依赖项都安装良好(我遵循了这些说明: https://github.com/Automattic/node-canvas/wiki/Installation---Amazon-Linux-AMI-(EC2) )。只是 elasticbeanstalk 部署造成了痛苦。

我尝试通过向 .ebextensions 内的 .config 文件添加命令来在部署期间启用 root 访问权限,如下所示:

option_settings:
- namespace: aws:elasticbeanstalk:container:nodejs:staticfiles
option_name: /public
value: /public
- option_name: NODE_ENV
value: production

commands:
01_enable_rootaccess:
command: echo Defaults:root \!requiretty >> /etc/sudoers
02_no-cert:
command: sudo /opt/elasticbeanstalk/node-install/node-v0.10.10-linux-x64/bin/npm config set ca ""

但似乎没有任何区别。

我做错了什么,如何在 eb 部署期间让 canvas 很好地安装?

最佳答案

你有canvas的所有依赖项吗?为了让它为我工作,我必须安装以下内容:cairocairo-devellibjpeg-devel giflib-devellibpng-devel(应该已经安装)。

您可以通过在 .ebextensions 之一中添加以下内容来确保安装所有这些内容:

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

我认为 Canvas 可能会尝试安装它没有但没有权限的东西。

尝试一下并让我知道它是如何工作的。

关于node.js - 在elasticbeanstalk上安装npm canvas - npm安装错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26066350/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com