Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.
What is a difference between installing npm module locally and globally?
Experience Level: Senior
When you install a module locally:
- It will be installed into your local folder.
- The module is then not visible outside of this folder.
- You can have multiple installations of the same module in different folders.
- You can install different versions of the same module side by side.
When you install a module globally:
- It can be used from all the other directories.
- Only one version of the module can be installed.
- You should install a module globally when you want to use it in multiple different projects without having a maintenance overhead.
Related npm job interview questions
How do you keep files out of your package when you publish a package using npm?npm Senior
Using npm, how do you publish a package to the public repository?npm Senior
Where can you find modules that the npm installed globally after you executed the npm install -g command?npm Senior
Using npm, how do you install a package from your local folder?npm Senior
What is a npm package?npm Junior