Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How are locally and globally installed packages different?

How are packages installed with the command

$ npm i -g <package_name>

different from the packages installed with the following command?

$ npm i <package_name>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The main difference between the locally installed and globally installed packages is that

  1. locally installed packages are kept inside the same directory that you run the npm install <package_name> and these packages are kept in the node_modules folder under that same directory.

  2. globally installed packages are all kept in the same directory(the exact location depends upon your system setup). These packages are kept in the same directory regardless of where you run the npm install -g <package_name> from.

Generally, it is suggested to install packages locally since updating a global package causes every application using that specific package to use the updated package and you might have to do the maintainence work, which is basically a nightmare.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading