如何为AWS Elastic Beanstalk部署运行npm脚本? [英] How can I run an npm script for an AWS Elastic Beanstalk Deployment?

查看:102
本文介绍了如何为AWS Elastic Beanstalk部署运行npm脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的package.json具有:

  "scripts": {
    "start": "node_modules/.bin/coffee server.coffee",
    "test": "NODE_ENV=test node test/runner.js",
    "coverage": "NODE_ENV=test COVERAGE=1 node test/runner.js -R html-cov test/ > ./test/coverage.html",
    "testw": "fswatch -o test src | xargs -n1 -I{} sh -c 'coffeelint src server.coffee ; npm test'",
    "db:drop": "node scripts/drop-tables.js",
    "encryptConfig": "node_modules/.bin/coffee config/encrypt.coffee",
    "decryptConfig": "node_modules/.bin/coffee config/decrypt.coffee",
    "postinstall": "npm run decryptConfig"
  },

当我部署到Elastic Beanstalk时,我想运行postinstall,但是显然它没有这样做.好的,没问题.

When I deploy to Elastic Beanstalk, I'd like to run the postinstall, but apparently it doesn't do that. Okay, no problem.

我创建了一个名为.ebextensions/00.decrypt.config的文件,该文件具有:

I created a file called .ebextensions/00.decrypt.config which has:

commands:
  00-add-home-variable:
    command: sed -i 's/function error_exit/export HOME=\/root\n\nfunction error_exit/' /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh

container_commands:
  02-decrypt-config:
    command: $NODE_HOME/bin/npm run decryptConfig

但是,这似乎也没有运行.我在做什么错?

However this doesn't seem to run either. What am I doing incorrectly?

推荐答案

一些建议:

  • 尝试将命令括在引号中,这是必需的
  • 此外,不确定$ NODE_HOME是否正常-您可以运行简单的测试,例如echo $ NODE_HOME>/tmp/test.txt吗?

这篇关于如何为AWS Elastic Beanstalk部署运行npm脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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