When I start a new Rails project, it gives me a template with a few different files for packages: Gemfile, package.json, and yarn.lock. I’m trying to understand if all three of these packages work together, or if I’m supposed to choose one. For example, in my Gemfile, I can add ‘jquery-rails’ but is this the same as installing jQuery to my package.json file? I’m having trouble understanding the difference between running bundle install and npm install.
In short it looks like this:
In Ruby, the
bundler analyzes the list of libraries (gems) specified in the
Gemfile, builds a dependency tree and fixes it in
Gemfile.lock, downloads gems from different sources
In JS, various managers do the same:
bower, etc. By default Rails use
yarn. They download all libraries to
package.json is analogue of
Gemfile (but more advanced, for example you can define command line scripts there).
yarn.lock is analogue of
bundler for Ruby and
npm for JS libraries
Answered By – mechnicov
Answer Checked By – David Marino (Easybugfix Volunteer)