处理node.js私有模块依赖项的推荐方法是什么?

Gin*_*ger 5 deployment amazon-web-services node.js amazon-elastic-beanstalk

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

"ModuleName": "git+https://TOKEN:x-oauth-basic@github.com/OWNER/REPO_NAME.git"
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试部署到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'}
Run Code Online (Sandbox Code Playgroud)

通过阅读我可以看出,似乎git没有安装在Beanstalk使用的默认linux AMI上.我的问题是处理这个问题的最佳方法是什么.目前我正在考虑以下两个选项:

  1. 要么使用安装了git的AMI,要么在引导期间以某种方式强制安装.
  2. 创建一个构建过程,在部署到Beanstalk之前打包我的所有node_modules.

这两个选项是否有意义,还是我应该考虑其他选择?是否有推荐的方法来处理Elastic Beanstalk或一般的节点生态系统?

Vig*_*son 3

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

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

#extra yum packages
packages:
  yum:
    git: []
Run Code Online (Sandbox Code Playgroud)

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