- Published on
Understanding Gem with prior knowledge of npm
- Authors
- Name
- hwahyeon
A Gem is a package (library) used in the Ruby ecosystem. It is similar to npm packages in the JavaScript/Node.js ecosystem, containing reusable code written in Ruby. Examples of popular Gems include Jekyll, Rails, and Devise.
Category | Gem | npm |
---|---|---|
Language | Ruby | JavaScript/Node.js |
Package Manager | RubyGems (gem command) | npm (npm command) |
Dependency Tool | Bundler | npm |
Dependency Files | Gemfile , Gemfile.lock | package.json , package-lock.json |
Execution Command | bundle exec [command] | npx [command] |
Global Install | gem install [package_name] | npm install -g [package_name] |
Project Install | bundle install | npm install |
Script Execution | bundle exec for Gems (e.g., Jekyll, Rails) | npm run [script_name] |
Package Deployment | gem build [package_name].gemspec → gem push | npm publish |
Package Structure | A RubyGem consists of Ruby code and a .gemspec file | An npm package consists of package.json and related files |
Version Specification | Specify versions in the Gemfile (gem 'package_name', '~> 2.0' ) | Specify versions in package.json ("package_name": "^2.0.0" ) |
Local Execution | Execute Gems with bundle exec | Use npx or run from the project's node_modules folder |