I've been working on a lot of different node.js projects. All of them have their own package.json
file with their own needed packages. Every time I run node <mainfile>.js
, npm installs all the packages to the project directory. Like so: C:/Users/me/Projects/<project-name>/node_modules
.
This isn't a very big problem, but is there a way to make npm use/install to the global packages? Like in C:/Users/me/node_modules
?
One of the advantages I could see this having is less storage being taken up, although it isn't a huge advantage.
I would assume that if it is possible, it would require you to add/modify something in the package.json
file.
While looking into answers for this question, I've seen people saying that you should avoid installing packages globally. Can you also explain why this is a bad practice andy why I should avoid it?