我目前正在开发一个部署在Elastic Beanstalk上的node.js应用。它已经开始引用作为私有存储库托管在github上的私有模块。本地,如果我在我的package.json的依赖项部分中添加对它的引用,如下所示它工作正常。我可以运行nom install,下载模块,应用程序可以正常运行。
"ModuleName": "git+https://TOKEN:x-oauth-basic@github.com/OWNER/REPO_NAME.git"
但是,当我尝试部署到Beanstalk时,它失败并出现以下错误:
2014-04-04 00:14:09,188 [DEBUG] (1630 MainThread) [commandWrapper.py-60] [root commandWrapper main] Command result: {'status': 'FAILURE', 'results': [{'status': 'FAILURE', 'config_sets': ['Infra-EmbeddedPreBuild', 'Hook-PreAppDeploy', 'Infra-EmbeddedPostBuild'], 'returncode': 1, 'events': [{'msg': 'Failed to run npm install. Snapshot logs for more details.', 'timestamp': 1396570449, 'severity': 'ERROR'}, {'msg': 'Failed to run npm install. npm http GET https://registry.npmjs.org/express\nnpm ERR! not found: git\nnpm ERR! \nnpm ERR! Failed using git.\nnpm ERR! This is most likely not a problem with npm itself.\nnpm ERR! Please check if you have git installed and in your PATH.\n\nnpm ERR! System Linux 3.4.73-64.112.amzn1.x86_64\nnpm ERR! command "/opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/npm" "install"\nnpm ERR! cwd /tmp/deployment/appli', 'timestamp': 1396570449, 'severity': 'ERROR'}], 'msg': 'Error occurred during build: Command hooks failed\n'}], 'api_version': '1.0'}
通过阅读我可以看出,似乎git没有安装在Beanstalk使用的默认linux AMI上。我的问题是处理这个问题的最佳方法是什么。目前我正在考虑以下两个选项:
这两个选项有意义还是我应该考虑其他选择?是否有推荐的方法来处理Elastic Beanstalk或一般的节点生态系统?
答案 0 :(得分:3)
您可以通过在.ebextensions文件夹中添加配置文件来确保在计算机上安装了git。见http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
如果添加名为.ebextensions / packages.config的文件,其中包含以下内容:
#extra yum packages
packages:
yum:
git: []
这将在安装您的应用程序之前在计算机上安装git。