npm 在哪里安装包? [英] Where does npm install packages?
问题描述
谁能告诉我在哪里可以找到使用 npm
安装的 Node.js 模块?
Can someone tell me where can I find the Node.js modules, which I installed using npm
?
推荐答案
全局库
您可以运行 npm list -g
来查看安装了哪些全局库以及它们所在的位置.使用 npm list -g |head -1
用于仅显示路径的截断输出.如果您只想显示主软件包而不是与其一起安装的子软件包 - 您可以使用 - npm list --depth=0
这将显示所有软件包并仅获取全局安装的软件包,只需添加 -g 即 npm list -g --depth=0
.
Global libraries
You can run npm list -g
to see which global libraries are installed and where they're located. Use npm list -g | head -1
for truncated output showing just the path. If you want to display only main packages not its sub-packages which installs along with it - you can use - npm list --depth=0
which will show all packages and for getting only globally installed packages, just add -g i.e. npm list -g --depth=0
.
在 Unix 系统上,当全局安装时,它们通常放在 /usr/local/lib/node
或 /usr/local/lib/node_modules
中.如果将 NODE_PATH
环境变量设置为此路径,则可以通过节点找到模块.
On Unix systems they are normally placed in /usr/local/lib/node
or /usr/local/lib/node_modules
when installed globally. If you set the NODE_PATH
environment variable to this path, the modules can be found by node.
Windows XP - %USERPROFILE%AppData
pm
ode_modules
Windows 7、8 和 10 - %USERPROFILE%AppDataRoaming
pm
ode_modules
Windows XP - %USERPROFILE%AppData
pm
ode_modules
Windows 7, 8 and 10 - %USERPROFILE%AppDataRoaming
pm
ode_modules
非全局库安装在您当前所在文件夹中的 node_modules
子文件夹中.
Non-global libraries are installed the node_modules
sub folder in the folder you are currently in.
您可以运行 npm list
来查看您当前位置安装的非全局库.
You can run npm list
to see the installed non-global libraries for your current location.
npm install -g pm2
- pm2 将被全局安装.然后通常会在 /usr/local/lib/node_modules
中找到它(使用 npm root -g
来检查位置.)
npm install -g pm2
- pm2 will be installed globally. It will then typically be found in /usr/local/lib/node_modules
(Use npm root -g
to check where.)
npm install pm2
- pm2 将安装在本地.然后通常会在 /node_modules
这篇关于npm 在哪里安装包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!