What is the difference between ‘Local installation’ and ‘Global installation’?Knowledge in 3 minutes

General

When installing packages using the npm command, which manages Nod.js libraries and packages, there are two concepts: local installation and global installation.

The installation location differs between local installation and global installation.

In this article, I would like to explain the difference between local installation and global installation.

What is local installation?

Install packages for each project. This allows version control of libraries, etc. for each project.

Local installation requires passing through the path after installation.

An example of a local install command is shown below

npm install --save-dev <package name>

What is Global installation?

The installation will be performed at the location where the path leads to. For this reason, global installation is suitable for commands that are commonly used in all projects.

Examples of global install commands are

sudo npm install --global <package name>

However, global installations naturally do not allow for version switching from one project to another. Also, some projects may stop working due to version upgrades, etc.

This is a 3-minute explanation of local and global installation with npm.