Open In App

What is global installation of dependencies in Node.js ?

The global installation of dependencies in Node.js is putting global packages in a single place in the system exactly where it depends on your setup, regardless of where you run the command npm install -g <package-name> to install dependencies.

Prerequisites:



Node JS: Node.js is an open-source and cross-platform runtime environment built on Chrome’s V8 JavaScript engine for executing JavaScript code outside of a browser. You need to recollect that NodeJS isn’t a framework, and it’s not a programming language.

React JS: React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It’s ‘V’ in MVC. ReactJS is an open-source, component-based front-end library responsible only for the view layer of the application.



  
Syntax:

run npm install -g <package-name>

Where g denotes a global mode of a variable.

Application: It is used to install packages globally in the system while making Node projects.

Path of Global Packages in the system: Global modules are installed in the standard system in root location in the system directory  /usr/local/lib/node_modules project directory.

Command to print the location on your system where all the global modules are installed. 

npm root -g

Output: 

C:\Users\Pallavi\AppData\Roaming\npm\node_modules

Example to illustrate how to install the package globally in the system.

Write this command in the console. 

npm install -g mit-license-generator

Output: 

How to check which packages are installed globally in the system. 

npm list -g

The output will be: 

Advantages:

Disadvantages:

 

Article Tags :