node.js - ElasticBeanstalk 上的 Meteor 部署失败

标签 node.js meteor amazon-elastic-beanstalk

到目前为止我很喜欢MeteorJS。也许那些已经部署到 EB 的人可以帮助我。

我能够成功地将我的应用程序部署到 EB,但后续部署失败。在 npm 安装阶段,我收到如下错误消息

  gyp ERR! node -v v0.10.42
  gyp ERR! node-gyp -v v1.0.1
  gyp ERR! not ok 

  npm ERR! bcrypt@0.8.5 install: `node-gyp rebuild`
  npm ERR! Exit status 1
  npm ERR! 
  npm ERR! Failed at the bcrypt@0.8.5 install script.
  npm ERR! This is most likely a problem with the bcrypt 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 bcrypt
  npm ERR! There is likely additional logging output above.
  npm ERR! System Linux 4.1.17-22.30.amzn1.x86_64
  npm ERR! command "/opt/elasticbeanstalk/node-install/node-v0.10.42-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v0.10.42-linux-x64/bin/npm" "--production" "rebuild"
  npm ERR! cwd /tmp/deployment/application
  npm ERR! node -v v0.10.42
  npm ERR! npm -v 1.4.29
  npm ERR! code ELIFECYCLE
  npm ERR! 
  npm ERR! Additional logging details can be found in:
  npm ERR!     /tmp/deployment/application/npm-debug.log
  npm ERR! not ok code 0
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v0.10.42-linux-x64/bin/npm
  Setting npm config jobs to 1

我正在使用iron CLI 来构建我的应用程序。我用来部署的脚本看起来有点像这样:

rm -Rf build/bundle

iron build --server=https://my-domain.com --architecture os.linux.x86_64

eb deploy prod

项目根目录的package.json如下所示:

{
  "name": "trail-status",
  "version": "2.0.0",
  "scripts": {
    "start": "node build/bundle/main.js"
  },
  "dependencies": {
    "fibers": "1.0.1",
    "underscore": "*",
    "source-map-support": "*",
    "semver": "*",
    "bcrypt": "*"
  }
}

我尝试删除 build/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt 但运气不佳。还尝试从 package.json 中删除 bcrypt。

最佳答案

我发现解决这个问题的方法是使用 demeteorizer 来构建我的项目。这是我的脚本,非常适合部署。

rm -Rf elasticbeanstalk
rm -Rf build.zip

cd app

demeteorizer -a os.linux.x86_64 -o ../elasticbeanstalk

cd ..

zip -r build.zip elasticbeanstalk .ebextensions/ .elasticbeanstalk/ config/production
rm -Rf elasticbeanstalk

eb deploy production

rm -Rf build.zip

然后在 .ebextensions/configuration.config 中

files:
  "/opt/elasticbeanstalk/hooks/appdeploy/pre/51install_meteor.sh" :
    mode: "000755"
    user: root
    group: root
    encoding: plain
    content: |
      #!/usr/bin/env bash
      echo !!!  Setting up METEOR dependencies
      export PATH=$PATH:/usr/local/bin
      echo !!!  Set PATH: $PATH
      ln -s /opt/elasticbeanstalk/node-install/node-v0.10.42-linux-x64/bin/node /usr/local/bin/node
      ln -s /opt/elasticbeanstalk/node-install/node-v0.10.42-linux-x64/bin/npm /usr/local/bin/npm
      export HOME=/home/ec2-user
      echo !!!  Creating app bundle
      cd /tmp/deployment/application/elasticbeanstalk/bundle/programs/server
      npm install
      cd /usr/local/bin
      rm npm node

关于node.js - ElasticBeanstalk 上的 Meteor 部署失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35999696/

相关文章:

javascript - 我怎么知道 node.js 需要的完整路径而不运行 require

javascript - Meteor 的 template.rendered 在页面实际渲染之前调用

meteor - 在 Windows 上使用 Meteor 时,“RM”未被识别为内部或外部命令

Meteor 在根级别向用户帐户添加其他字段

django - 将 django static 部署到 amazon s3

java - aws elastic beanstalk 上的 HTTP 到 HTTPS 不适用于 Spring Boot

node.js - 未处理的拒绝 SequelizeConnectionError : connect ENOENT

node.js - Sequelize node js create record with autoincrement field 验证错误

amazon-elastic-beanstalk - 如何通过 Elastic Beanstalk 部署(包括数据库补丁)避免停机?

node.js - NPM 没有安装任何模块 : network socket hangs up