【问题标题】:What is the recommended way to handle node.js private module dependencies?处理 node.js 私有模块依赖项的推荐方法是什么?
【发布时间】:2014-05-16 20:07:39
【问题描述】:

我目前正在开发一个部署在 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'}

据我所知,Beanstalk 使用的默认 linux AMI 上似乎没有安装 git。我的问题是处理这个问题的最佳方法是什么。目前我正在考虑以下两种选择:

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

这两个选项有意义还是我应该考虑其他选项?有没有推荐的方法来使用 Elastic Beanstalk 或在一般的节点生态系统中处理这个问题?

【问题讨论】:

标签: node.js amazon-web-services deployment amazon-elastic-beanstalk


【解决方案1】:

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

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

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

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

【讨论】:

    猜你喜欢
    • 2019-01-26
    • 2016-03-31
    • 1970-01-01
    • 2018-06-12
    • 2015-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多