Where does npm install packages?

有人可以告诉我在哪里可以找到使用npm安装的Node.js模块?


Global libraries

You can run npm list -g to see where global libraries are installed.

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%Application Datanpmnode_modules
Windows 7, 8 and 10 - %AppData%npmnode_modules

Non-global libraries

Non-global libraries are installed the node_modules sub folder in the folder you are currently in.

You can run npm list to see the installed non-global libraries for your current location.


The command npm root will tell you the effective installation directory of your npm packages.

If your current working directory is a node package or a sub-directory of a node package, npm root will tell you the local installation directory. npm root -g will show the global installation root regardless of current working directory.

See the documentation.


Use the npm root -g command for find out your global npm path.

Example:

$ npm root -g
/usr/local/lib/node_modules
链接地址: http://www.djcxy.com/p/27690.html

上一篇: 没有sudo,NPM模块将不会全局安装

下一篇: npm安装软件包在哪里?