Starting with NodeJS and NPM, a MEAN Stack project would include a package.json, which lists all the npm packages that are dependencies for the project. So basically, to setup a local development env, you run npm install and all the required packages gets magically saved into a folder called node_modules in the project directory. This process is automated by JS frameworks with CLIs such as Angular, which sets up an application structure and installs all the required dependencies.
Ruby on Rails follows this exact same concept for setting up. The Rails equivalents for npm packages, package.json and npm are Rubygems (commonly referred to as gems), Gemfile and bundler respectively. And Rails CLI by itself has a commands to setup a barebones application structure which also installs the gems, and sets up a basic database, for rapid development.
// Angular CLI ng new <project-name>
// Install package using NPM npm install <package-name>
// Rails CLI rails new <project-name>
// Install Rubygem gem install <gem-name>
// Install all packages in Gemfile (Something like npm install) bundler install
These similarities are not only just for project setup but also for running them. Ruby also comes with integrated full-stack which doesn’t require separate setup with frameworks such as ExpressJS for NodeJS and to ease things out even more it ships directly with a simple PostgreSQL database.
// Starting up a MEAN application with Node npm start
// If the application is built over a CLI such as Angular ng serve
// Starting up a Ruby on Rails application rails serve
Primary difference you notice in package management is that there are no global and local packages like in NPM, which uses this method to prevent version conflicts as different projects may require different versions of the same package. Ruby on the other hand runs smooth with all it’s gems being installed globally and taken care of by bundler. Basically it has no local equivalent to node_modules and installs the packages system-wide to be shared by all your projects.
Talking about databases, NodeJS uses npm packages which acts as an interface or driver to connect to MongoDB, MySQL or so. RoR already comes with PostgreSQL by default, with capabilities to work directly with it from the CLI as well an web GUI interface.
I don’t think I need to actually say it out loud at this point, it’s pretty clear that albeit the differences, switching between both is pretty easy, as concept wise it’s a lot similar.