简体   繁体   English

AWS Elastic BeanStalk nodejs部署错误

[英]AWS Elastic BeanStalk nodejs Deployment error

I am stuck in a very weird issue from the last two days. 在过去的两天里,我陷入了一个非常奇怪的问题。 I am trying to deploy my webpack nodejs app on AWS elastic beanstalk. 我正在尝试在AWS弹性beanstalk上部署我的webpack nodejs应用程序。 The Environment Health changes from OK to Degraded . 环境运行状况从“ 正常”更改为“ 降级” I have deployed it many times before but no such issue occurred. 我之前已多次部署它,但没有发生这样的问题。 First of all, see the logs: 首先,请参阅日志:

/var/log/eb-activity.log /var/log/eb-activity.log

/opt/elasticbeanstalk/containerfiles/ebnode.py --action node-install Activity execution failed, because: + /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install /opt/elasticbeanstalk/containerfiles/ebnode.py --action node-install活动执行失败,原因是:+ / opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install

npm ERR! 错误的ERR! path /tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp npm ERR! path /tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp npm ERR! code EEXIST npm ERR! 代码EEXIST npm ERR! Refusing to delete /tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp: is outside /tmp/deployment/application/node_modules/grpc/node_modules/node-pre-gyp and not a link 拒绝删除/tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp:在/ tmp / deployment / application / node_modules / grpc / node_modules / node-pre-gyp之外,而不是链接

npm ERR! 错误的ERR! File exists: /tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp npm ERR! 文件存在:/tmp/deployment/application/node_modules/grpc/node_modules/.bin/node-pre-gyp npm ERR! Move it away, and try again. 将它移开,然后再试一次。 npm ERR! 错误的ERR! A complete log of this run can be found in: npm ERR! 可以在以下位置找到此运行的完整日志:npm ERR! /tmp/.npm/_logs/2018-09-18T05_49_17_967Z-debug.log Running npm install: /opt/elasticbeanstalk/node-install/node-v8.9.3-linux-x64/bin/npm /tmp/.npm/_logs/2018-09-18T05_49_17_967Z-debug.log运行npm install:/opt/elasticbeanstalk/node-install/node-v8.9.3-linux-x64/bin/npm
Setting npm config jobs to 1 npm config jobs set to 1 Running npm with --production flag Failed to run npm install. 将npm配置作业设置为1 npm配置作业设置为1使用--production flag运行npm无法运行npm install。 Snapshot logs for more details. 快照日志以获取更多详细信息。 UTC 2018/09/18 05:49:17 cannot find application npm debug log at /tmp/deployment/application/npm-debug.log Traceback (most recent call last): File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 695, in main() File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 677, in main node_version_manager.run_npm_install(options.app_path) File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 136, in run_npm_install self.npm_install(bin_path, self.config_manager.get_container_config('app_staging_dir')) File "/opt/elasticbeanstalk/containerfiles/ebnode.py", line 180, in npm_install raise e subprocess.CalledProcessError: Command '['/opt/elasticbeanstalk/node-install/node-v8.9.3-linux-x64/bin/npm', '--production', 'install']' returned non-zero exit status 1 (ElasticBeanstalk::ExternalInvocationError) UTC 2018/09/18 05:49:17在/tmp/deployment/application/npm-debug.log找不到应用程序npm调试日志Traceback(最近一次调用最后一次):文件“/opt/elasticbeanstalk/containerfiles/ebnode.py “,第695行,在main()文件”/opt/elasticbeanstalk/containerfiles/ebnode.py“中,第677行,在主node_version_manager.run_npm_install(options.app_path)文件”/opt/elasticbeanstalk/containerfiles/ebnode.py“中,第136行,在run_npm_install中self.npm_install(bin_path,self.config_manager.get_container_config('app_staging_dir'))文件“/opt/elasticbeanstalk/containerfiles/ebnode.py”,第180行,在npm_install中提升e subprocess.CalledProcessError:Command'[ '/opt/elasticbeanstalk/node-install/node-v8.9.3-linux-x64/bin/npm',' - production','install']'返回非零退出状态1(ElasticBeanstalk :: ExternalInvocationError)

Now the error is of some node-gyp module and trust me I haven't heard it before. 现在错误是一些node-gyp模块,相信我以前没有听过。 I am trying for a solution so that I can continue my work because this is really an embarrassing situation for me in front of my boss. 我正在尝试一个解决方案,以便我可以继续我的工作,因为这对我来说在我的老板面前真的是一个令人尴尬的局面。 Your help can get me out of this situation. 你的帮助可以让我摆脱这种局面。

Thanks 谢谢

I had the same problems with various node modules. 我遇到了各种节点模块的相同问题。 It was a simple toy project were I created the initial NodeJs express project using express init . 这是一个简单的玩具项目,我使用express init创建了最初的NodeJs express项目。

I found various posts about adding a file to the .ebextensions folder and ended up with this version: 我发现了有关将文件添加到.ebextensions文件夹的各种帖子,最终得到了这个版本:

Create a file called 01_delete_node_modules.config in the .ebextensions folder and add the following content: 在.ebextensions文件夹中创建名为01_delete_node_modules.config的文件,并添加以下内容:

files: "/opt/elasticbeanstalk/hooks/appdeploy/pre/49_delete_node_modules.sh": mode: "000755" owner: root group: root content: | #!/usr/bin/env bash sudo rm -rf /tmp/deployment/application/node_modules

Cudos to this blog post by Josh Harris: https://medium.com/@jharris.sf/npm-rebuild-elastic-beanstalk-and-permissions-be1c6fceba9a Josh Harris对此博客文章的评论: https ://medium.com/@jharris.sf/npm-rebuild-elastic-beanstalk-and-permissions-be1c6fceba9a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM