简体   繁体   English

npm 安装包在哪里?

[英]Where npm install the packages?

I have some mess with npm.我对 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.我正在尝试使用 npm 更新 npm 和其他库,但它没有更新,我尝试了一些解决方案,但它们对我没有用。

The following shows the pathnames returned when running;下面显示了运行时返回的路径名; npm root , npm root -g , and which npm via the command-line: npm rootnpm root -gwhich npm通过命令行:

 $ 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?

I can understand your confusion.我能理解你的困惑。 First of all, what is important to know, is that Node is the Software that is running your code.首先,重要的是要知道 Node 是运行代码的软件。 NPM is a package manager, which ships together when installing Node. NPM 是一个 package 管理器,在安装 Node.js 时一起提供。

As different projects require their specific Node Version, I like using NVM - the Node Version Manager.由于不同的项目需要其特定的节点版本,我喜欢使用 NVM - 节点版本管理器。

The node_modules Directory in your Home Folder exists because you probably have executed the npm install command inside your Home folder.主文件夹中的 node_modules 目录存在是因为您可能已经在主文件夹中执行了 npm 安装命令。 It has created the node_modules Directory and downloaded the packages in there.它创建了 node_modules 目录并在其中下载了包。 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.保持 HOME 目录尽可能干净是一个好习惯,没有理由将 node_modules 文件夹保留在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM