首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将node.js应用程序部署到亚马逊弹性豆茎时出错

将node.js应用程序部署到亚马逊弹性豆茎时出错
EN

Stack Overflow用户
提问于 2016-07-10 01:46:50
回答 6查看 8K关注 0票数 5

我最近在beanstalk上部署了一个新的node.js应用程序,并且一直运行以下错误?

实例: i-cce89e4a命令在实例上失败。返回代码:1输出:(TRUNCATED)...opt/elasticbeanstalk/containerfiles/ebnode.py",第180行,在命令日志raise e subprocess.CalledProcessError: Command ''/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/npm','--production','rebuild'‘中返回非零退出状态254。挂钩日志失败。有关详细信息,请使用控制台或EB /opt/elasticbeanstalk/hooks/configdeploy/pre/50npm.sh查看/ npm_install /subprocess.CalledProcessError/EB-activity.log。

我的node版本是: 4.4.7

部署似乎在下面的最后一行失败:

代码语言:javascript
复制
 except Exception, e:
            npm_debug_log = '/var/log/nodejs/npm-debug.log'
            app_npm_debug_log = os.path.join(app_path, "npm-debug.log")
            write_event('Failed to run npm install. Snapshot logs for more details.', 'ERROR')
            if not os.path.exists(app_npm_debug_log):
                utc_time_str = datetime.datetime.utcnow().strftime("UTC %Y/%m/%d %H:%M:%S")
                err_msg = str.format("{0} cannot find application npm debug log at {1} \n", utc_time_str, app_npm_debug_log)
                print(err_msg)
                with open(npm_debug_log, 'a') as f:
                    f.write(err_msg)
            else:
                shutil.copyfile(app_npm_debug_log, npm_debug_log)
            raise e

我似乎找不到任何可靠的解决方案?

我手动压缩并上传了这些文件。

这个应用程序在本地运行得很好。

有人能帮上忙吗?

代码语言:javascript
复制
Application deployment failed at 2016-07-09T18:47:38Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh failed.

+ /opt/elasticbeanstalk/containerfiles/ebnode.py --action npm-install
npm WARN package.json dashboard@0.0.2 No repository field.

> history@1.17.0 postinstall /tmp/deployment/application/node_modules/history
> node ./npm-scripts/postinstall.js

npm ERR! Linux 4.4.14-24.50.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v4.4.6-linux-x64/bin/npm" "--production" "rebuild"
npm ERR! node v4.4.6
npm ERR! npm v2.15.5
npm ERR! path /tmp/deployment/application/node_modules/gulp-main-bower-files/node_modules/main-bower-files/node_modules/vinyl-fs/node_modules/duplexify/node_modules/readable-stream/node_modules/unreachable-branch-transform/node_modules/recast/node_modules/esprima/bin/esvalidate.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod '/tmp/deployment/application/node_modules/gulp-main-bower-files/node_modules/main-bower-files/node_modules/vinyl-fs/node_modules/duplexify/node_modules/readable-stream/node_modules/unreachable-branch-transform/node_modules/recast/node_modules/esprima/bin/esvalidate.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR! /tmp/deployment/application/npm-debug.log
Running npm install: /opt/elasticbeanstalk/node-install/node-v4.4.6-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. Snapshot logs for more details.
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-v4.4.6-linux-x64/bin/npm', '--production', 'rebuild']' returned non-zero exit status 254.
EN

回答 6

Stack Overflow用户

发布于 2016-07-10 02:06:45

我没有足够的信息来回答.../var/log/eb-activity.log显示什么?

...But我遇到了一个类似的错误,当运行npm安装的豆茎与t2.mall:它没有足够的内存,npm失败。升级到更大的实例可以解决问题。(提交node_module也可以解决这个问题,但我并不想这样做)。

您应该做的是使用SSH连接到实例,并观察部署时top/htop发生的情况。

票数 6
EN

Stack Overflow用户

发布于 2020-02-26 02:14:24

数小时后搜索部署失败的原因。我可以说,以下任何一点都可以解决问题。

将elacticbeanstalk configuration

  • Change实例类型中的

  • to版本从elacticbeanstalk configuration

  • Or中的t2.micro更改为t2.small在elacticbeanstalk

  • 中启动节点应用程序(根据您的要求)时运行的新命令在根项目中使用此content

创建.npmrc文件

代码语言:javascript
复制
# Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm@5
unsafe-perm=true
票数 5
EN

Stack Overflow用户

发布于 2016-07-10 05:44:31

我之前在我的压缩文件中包含了我的node_modules文件夹。排除此文件夹解决了问题

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38284605

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档