Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

node.js - Where npm install the packages?

I have some mess with npm. I'm trying to update npm and other libs with npm but it doesn't update, I tried some solutions but they haven't worked for me.

The following shows the pathnames returned when running; npm root, npm root -g, and which npm via the command-line:

$ npm root
/Users/MYUSER/node_modules
$ npm root -g
/usr/local/Cellar/node/13.7.0/lib/node_modules
$ which npm
/usr/local/bin/npm

Can you help me understand what is wrong here?
question from:https://stackoverflow.com/questions/65832449/where-npm-install-the-packages

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I can understand your confusion. First of all, what is important to know, is that Node is the Software that is running your code. NPM is a package manager, which ships together when installing Node.

As different projects require their specific Node Version, I like using NVM - the Node Version Manager.

The node_modules Directory in your Home Folder exists because you probably have executed the npm install command inside your Home folder. It has created the node_modules Directory and downloaded the packages in there. It is a good practice to keep your HOME Directory as clean as possible, and there is no reason to keep the node_modules Folder there.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...