Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the recommended way to handle node.js private module dependencies?

I am currently working on an node.js app that is deployed on Elastic Beanstalk. It has started to reference a private module that is hosted on github as a private repository. Locally if I put a reference to it in the dependency section of my package.json like the following it works fine. I can run nom install, it downloads the module and the app works without issue.

"ModuleName": "git+https://TOKEN:[email protected]/OWNER/REPO_NAME.git"

However, when I try to deploy to Beanstalk it fails with the following error:

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'}

From what I can tell by reading that it appears that git is not installed on the default linux AMI that Beanstalk uses. My question is what is the best way to handle this. Currently I'm considering the following two options:

  1. Either use an AMI that has git installed or force the installation somehow during boot.
  2. Create a build process that packages all my node_modules prior to deploying to Beanstalk.

Do these two options make sense or should I be considering another option? Is there a recommended way to handle this with Elastic Beanstalk or in the node ecosystem in general?

like image 294
Ginny Dellinger Avatar asked Oct 21 '22 11:10

Ginny Dellinger


1 Answers

You can make sure that git is installed on the machine by adding a config file in the .ebextensions folder. See http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

If you add a file called .ebextensions/packages.config which contains the following:

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

This will install git on the machine before installation of your application.

like image 113
Vignir Hafsteinsson Avatar answered Oct 23 '22 02:10

Vignir Hafsteinsson