GithubHelp home page GithubHelp logo

mixmaxhq / eb-fix-npm Goto Github PK

View Code? Open in Web Editor NEW
50.0 23.0 11.0 33 KB

[unsupported] Fixes npm in Elastic Beanstalk environments.

Home Page: https://www.mixmax.com/careers

License: MIT License

elasticbeanstalk npm ebextensions hooks eb-script unsupported

eb-fix-npm's Introduction

eb-fix-npm

This module installs an .ebextensions config file that will fix npm in various ways in AWS Elastic Beanstalk to make your deploys faster and more reliable.

TL;DR This module makes it possible to upgrade from Node 4 to Node 6 on Elastic Beanstalk and speeds up npm install by 95%.

Looking for even bigger savings? You might consider disabling npm altogether. Mixmax no longer uses this module, though we will answer support questions to the best of our ability as well as accept others' PRs.

This module works by installing deployment hooks that perform setup and cleanup related to Elastic Beanstalk's use of npm:

  • Downgrade npm to npm 2 because npm 3 is too slow to install packages for EB (deploys will time out)
  • Cache Node modules between deploys
  • Only install (don't rebuild) Node modules on application deploy
  • Only rebuild (don't install) Node modules on configuration deploy (EB's script tries to both install and rebuild)
  • Actually rebuild Node modules on configuration deploy (EB's script uses the the wrong directory and so just aborts)
  • Remove npm temp files leftover by installing from shrinkwrap

The hooks expect that your Elastic Beanstalk application is using either platform version 3.1.0 or the previous version, version 2.1.3. It may work with newer versions—if it does not, PRs are welcome!

Installation

  1. npm install eb-fix-npm --save-dev (see here for why --save-dev)
  2. Commit the .ebextensions file it creates.
  3. Deploy.

Modifying the .ebextensions file

This module will overwrite the file if/when it is updated.

Pull requests are welcome if you have some generally-useful modifications to suggest.

If you'd like to make modifications specific to your use case, you should uninstall this module after installing the .ebextensions file. Uninstallation won't take the file with it.

Acknowledgements

Some of the hooks are based on logic from https://github.com/kopurando/better-faster-elastic-beanstalk.

Release History

  • 1.2.5 Use the runtime Node version
  • 1.2.4 Set proper home directory
  • 1.2.3 Fix rebuild directory
  • 1.2.2 Misc fixes
  • 1.2.1 Use user's environment variables with npm
  • 1.2.0 Avoid unnecessarily installing/rebuilding Node modules
  • 1.1.0 Cache Node modules between deploys
  • 1.0.0 Initial commit

eb-fix-npm's People

Contributors

bradvogel avatar gaastonsr avatar megantinleywilson avatar strathausen avatar wearhere avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eb-fix-npm's Issues

Unable to install

node_modules\install-files\src\hostPackageDir.js:12
var pathComponents = file.split(path.sep);
^
TypeError: Cannot read property 'split' of undefined
at hostPackageDir (C:\Users\user\untitled\node_modules\install-files\src\hostPackageDir.js:12:28)
at installFiles (C:\Users\user\untitled\node_modules\install-files\src\index.js:45:35)
at Object. (C:\Users\user\untitled\node_modules\install-files\bin\install-files.js:16:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "eb-fix-npm" "--save-dev"
npm ERR! node v7.10.0
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1

npm ERR! [email protected] install: install-files source
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'install-files source'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the eb-fix-npm package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! install-files source
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs eb-fix-npm
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls eb-fix-npm
npm ERR! There is likely additional logging output above.

Deployment broken

When I try to deploy a new version of my app, I get this error from Elastic Beanstalk :

Command failed on instance. Return code: 1 
Output: ln: failed to create symbolic link ‘/tmp/deployment/application/node_modules’: File exists. 
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/46cache_node_modules.sh failed. 
For more detail, check /var/log/eb-activity.log using console or EB CLI.

Did I miss something ?

npm ERR! This request requires auth credentials. Run `npm login` and repeat the request.

Application update failed at 2017-07-06T15:21:52Z with exit status 1 and error: Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/45npm_downgrade.sh failed.

Downgrading npm to 2.15.9...
npm ERR! Linux 4.9.32-15.41.amzn1.x86_64
npm ERR! argv "/opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v6.10.0-linux-x64/bin/npm" "install" "[email protected]" "-g"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10

npm ERR! This request requires auth credentials. Run `npm login` and repeat the request.
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR! 

npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.log.
Incorrect application version "app-094f-170706_161943" (deployment 23). Expected version "app-5c07-170705_224015" (deployment 11).
Following services are not running: application.

I'v tried adding this to the file and adding NPM_TOKEN variables but it doesnt work

"/tmp/.npmrc":
    mode: "000777"
    owner: root
    group: root
    content: |
      _auth=${NPM_TOKEN}
      always-auth=true
      registry=https://www.npmjs.com/~my-npm
      strict-ssl=true
      [email protected]

max_old_space_size

Hey all,

I want to use this plugin with max_old_space_size. How can i add this on fix-npm.config file? Because i also want to use t2.micro servers but, because of the standard nodejs memory size, i cannot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.