本文介绍了由于目录权限,Node.js部署在Amazon Elastic Beanstalk上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用命令行工具在Elastic Beanstalk上安装一个简单的Node.js应用程序.

I am try to install a simple Node.js application on Elastic Beanstalk using the command line tools.

在我的git存储库中,运行命令

On my git repository I run the command

$ eb deploy

部署git仓库的内容.部署良好,但是应用程序的运行状况为红色.

to deploy the contents of my git repository. It deploys fine however the Health status of the application is Red.

如果我查看Elastic Beanstalk网站上的日志,它会向我指出日志中的以下错误:

If I look at the logs on the Elastic Beanstalk website, it points me to the following error in the logs:

> [email protected] install /tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents
> node-pre-gyp install --fallback-to-build

gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents/build'
gyp ERR! stack at Error (native)
gyp ERR! System Linux 4.1.17-22.30.amzn1.x86_64
gyp ERR! command "/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v46-linux-x64/fse.node" "--module_name=fse" "--module_path=/tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v46-linux-x64"
gyp ERR! cwd /tmp/deployment/application/node_modules/nodemon/node_modules/chokidar/node_modules/fsevents
gyp ERR! node -v v4.3.0
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok

我尝试了各种事情,例如:

I tried various things like:

  1. 自己创建目录(目录归root拥有).
  2. 从/tmp中删除所有内容,以便下次修复时可以实现.
  3. 删除我的node_modules目录.

这些选项都不起作用,我找不到解决方法或发生这种情况的原因.我可以在本地运行node.js应用程序,也可以将其部署到Azure和Heroku,而不会出现任何问题.

None of these options work and I can't find a workaround or a reason why this happens. I can run the node.js app locally as well as deploy it to Azure and Heroku without any issues.

推荐答案

我有一个类似的问题,但是没有使用eb进行部署,并且没有在软件包中包含node_modules/.对我有用的解决方案是在.npmrc中设置unsafe-perm=true-请参见

I had a similar problem but wasn't using eb to deploy and did not include node_modules/ in the package. The solution that worked for me was to set unsafe-perm=true in .npmrc - see Beanstalk: Node.js deployment - node-gyp fails due to permission denied

这篇关于由于目录权限,Node.js部署在Amazon Elastic Beanstalk上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 20:39