Open In App

What is global installation of dependencies in Node.js ?

Last Updated : 29 Jul, 2021
Like Article

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.

  • Installing the local dependencies means the module will be available only for a project you installed in the same directory.
  • Global installing dependencies puts the module into your Node. js path, which is Operating System dependent) and will be accessible from any project without the need to install it separately for each project while doing the setup.
  • They allow us to use the packaging as a tool anywhere on the local computer.


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.


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



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

Write this command in the console. 

npm install -g mit-license-generator


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

npm list -g

The output will be: 


  • We do not need to install a module every time when installed globally.
  • It takes less memory as only one copy is installed.
  • We can make .js scripts and run them anywhere without having a node_modules folder in the same directory when packages are installed globally.


  • when we are running a Node app other than a local machine, then it will give an error because it needs packages in package.json that i.e, local packages.
  • Globally deployed packages cannot be imported using require() in Node application directly.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads