在Elastic Beanstalck上运行npm安装时出现问题 [英] Problems running npm install on Elastic Beanstalck

查看:179
本文介绍了在Elastic Beanstalck上运行npm安装时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Laravel(5.4)应用程序,它使用npm,bower和gulp作为前端.

I have a Laravel (5.4) application that uses npm, bower and gulp for frontend.

我已经成功配置了所有部署,但是npm installnpm install --production(在我的情况下是相同的)命令给我错误,并使部署失败.

I have configured all with success on deploy but the npm install or npm install --production (that in my case is the same) command give me errors and makes the deploy to fail.

这是我运行eb deploy命令时来自AWS的原因".

Here is the "Causes" as response from AWS when i run eb deploy command.

Application update failed at 2017-06-07T17:08:38Z with exit status 1 and error: container_command 01-npm-install in .ebextensions/05-frontend-install.config failed.

npm WARN lifecycle npm is using /usr/bin/node but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN prefer global node-gyp@3.6.2 should be installed with -g
npm WARN prefer global marked@0.3.6 should be installed with -g

> node-sass@3.13.1 install /var/app/ondeck/node_modules/node-sass
> node scripts/install.js

npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! node-sass@3.13.1 install: `node scripts/install.js`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the node-sass@3.13.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-06-07T17_08_38_740Z-debug.log.
Incorrect application version "app-5d9c-170607_190633" (deployment 40). Expected version "app-0466-170606_110037" (deployment 31).

.ebextensions/05-frontend-install.config文件具有此内容

container_commands:
  00-npm-upgrade:
    command: "npm install -g npm@latest"
  01-npm-install:
    command: "npm install --production"
  02-gulp-install:
    command: "sudo npm install gulp"
  03-bower-install:
    command: "sudo npm install bower"
  04-bower-deploy:
    command: "sudo bower install --allow-root"
  05-gulp-deploy:
    command: "sudo npm run prod"

推荐答案

实现了EB HOOK!

我通过使用自定义弹性豆茎post-deploy

Achived with an EB HOOK!

I solved my problem by using a custom elastic beanstalk post-deploy platform hook (sounds great eh?)

我的04-nodenpm.config文件具有以下内容:

my 04-nodenpm.config file has this content:

container_commands:
  00-entersudoi:
    command: "sudo -i"
  01-removeoldnode:
    command: " yum remove -y nodejs npm"
  02-get-noderpm:
    command: " curl --silent --location https://rpm.nodesource.com/setup_7.x | bash -"
  03-ensurecggmake:
    command: " yum install -y gcc-c++ make"
  04-installnodenpm:
    command: " yum install -y nodejs"
  05-exitsudoi:
    command: "exit"

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/99npminstall.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      cd /var/app/current/
      sudo npm install -g gulp bower laravel-elixir
      sudo bower install --allow-root
      sudo gulp --production

解决问题的部分位于files:下,其中我手动添加一个带有content:/opt/elasticbeanstalk/hooks/appdeploy/post/99npminstall.sh文件,该文件作为部署后操作使npm install ...和所有其他内容我想要.

The part that solved the problem is under files: where i am manually adding an /opt/elasticbeanstalk/hooks/appdeploy/post/99npminstall.sh file with content: that as a post deploy action makes the npm install ... and all the stuff i wanted.

npm在container_commands上似乎并不完全可用.使用部署后挂钩触发这些npm安装命令.

npm seems not be totally available on container_commands. Use a post deploy hook to fire those npm installation commands.

Refs&有用的链接:

Refs & Usefull links:

http://www.eq8.eu/blogs/29 -aws-elasticbeanstalk-部署钩子 https://forums.aws.amazon.com/thread.jspa?threadID= 137136

这篇关于在Elastic Beanstalck上运行npm安装时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆