在Elasticbeanstalk上安装npm canvas-npm安装错误

阿里·帕尔(Ali Parr)

我正在尝试通过Elasticbeanstalk部署在EC2上运行的node.js服务器。我遇到的问题是在canvas npm模块的重建过程中。命令“ [email protected] install:node-gyp rebuild”失败,如下所示:

> [email protected] 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! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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 SSH到服务器并运行“ sudo npm install canvas”,则一切正常。这告诉我所有适当的依赖项都已正确安装(我遵循以下说明:https : //github.com/Automattic/node-canvas/wiki/Installation---Amazon-Linux-AMI-(EC2))。只是造成了悲痛的是elasticbeanstalk部署。

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

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?

乔什·戴维斯(Josh Davis)

您是否拥有画布的所有依赖项?为了使其为我工作,我必须安装如下:cairocairo-devellibjpeg-develgiflib-devellibpng-devel(应该已经安装)。

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

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

我认为canvas可能正在尝试安装它没有权限的东西。

试试看,让我知道它是如何工作的。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章