How do I choose between JavaScript dependency frameworks?

How do I decide whether to use NPM or Bower to install dependencies?

e.g. What’s the difference between npm install requirejs --save-dev and bower install requirejs --save-dev?

  • Sharing frontend components between private projects
  • Add condition to gulp building process based on html attribute
  • Can I install Angular Material library without Bower or NPM?
  • Why Yeoman can't perform async callback after exec method?
  • Foundation 6 - Console Warning : Tried to initialize magellan (any JS plugin) on an element that already has a Foundation plugin
  • Bower throws jquery “not injected” warning after running grunt serve
  • Is there a ‘best practice’, or any way to choose?

    Are there any others that I need to be aware of?

  • What are npm, bower, gulp, Yeoman, and grunt good for?
  • Angular scripts missing in Yeoman-Angular generated app
  • How Can I Seamlessly Use A Local Bower Dependency?
  • SyntaxError: Unexpected end of input error using Gulp and main-bower-files package
  • using RequireJS for loading the jQuery Mobile bower component
  • How do I keep bower package dependencies out of my rollup bundle?
  • 3 Solutions collect form web for “How do I choose between JavaScript dependency frameworks?”

    As @seth-pollack pointed out, npm is mostly used for server-side dependencies and bower for client-side ones. But you could still use npm in front-end development for development dependencies, such as task runners (Grunt, Gulp, etc), test runners, lint checker, etc. Bower, on the other hand, is mostly used for dependencies that you want available in your deployed app.

    Use bower for front-end dependencies and NPM for server side.

    NPM is more geared for server side libraries, but, can be used for front end. Bower was created for front end libraries.

    Also NPM uses a nested dependency tree which has a much bigger footprint, while bower uses a flat dependency tree.

    Also, bower will force you to only have a single version of a library, while NPM will let you have multiple versions.

    Bower is better suited for front-end packages and has AMD libraries which you would use with RequireJS etc.

    NPM on the other hand has many libraries that are packaged as CommonJS modules. These would require you to use a build tool such as Browserify to make them usable in the browser.

    There is no reason why you shouldn’t use one or the other. You’ll have to pick the one that does the job.