什么是处理node.js私有模块依赖关系的推荐方式?

我目前正在使用部署在Elastic Beanstalk上的node.js应用程序。 它已经开始引用github上托pipe的私有模块作为私有存储库。 本地如果我把它的引用到我的package.json的依赖部分,如下所示,它工作正常。 我可以运行nom安装,它下载模块和应用程序没有问题。

"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上。 我的问题是处理这个问题的最好方法是什么。 目前我正在考虑以下两个选项:

  1. 请使用安装了git的AMI,或者在启动过程中以某种方式强制安装。
  2. 创build一个构build过程,在部署到Beanstalk之前,将所有的node_modules打包。

这两个select是否有意义,还是应该考虑另一种select? 有没有一种推荐的方式来处理Elastic Beanstalk或一般的节点生态系统?

您可以通过在.ebextensions文件夹中添加一个configuration文件来确保git安装在机器上。 请参阅http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

如果您添加一个名为.ebextensions / packages.config的文件,其中包含以下内容:

 #extra yum packages packages: yum: git: [] 

这将在安装应用程序之前在机器上安装git。