Where does npm install packages?

2019-01-01 04:23发布

Can someone tell me where can I find the Node.js modules, which I installed using npm?

17条回答
高级女魔头
2楼-- · 2019-01-01 04:54

In Ubuntu 14.04 they are installed at

/usr/lib/node_modules

查看更多
还给你的自由
3楼-- · 2019-01-01 04:56

On windows I used npm list -g to find out by default my (global) packages were being installed to C:\Users\[Username]\AppData\Roaming\npm.

查看更多
泪湿衣
4楼-- · 2019-01-01 04:56

You can find globally installed modules by the command

npm list -g

It will provide you the location where node.js modules have been installed.

C:\Users\[Username]\AppData\Roaming\npm

If you install node.js modules locally in a folder, you can type the following command to see the location.

npm list
查看更多
只靠听说
5楼-- · 2019-01-01 05:00

For globally-installed modules:

The other answers give you platform-specific responses, but a generic one is this:

When you install global module with npm install -g something, npm looks up a config variable prefix to know where to install the module.

You can get that value by running npm config get prefix

To display all the global modules available in that folder use npm ls -g --depth 0 (depth 0 to not display their dependencies).

If you want to change the global modules path, use npm config edit and put prefix = /my/npm/global/modules/prefix in the file.

When you use some tools like nodist, they change the platform-default installation path of global npm modules.

查看更多
倾城一夜雪
6楼-- · 2019-01-01 05:00

The easiest way would be to do

npm list -g

to list the package and view their installed location.

I had installed npm via chololatey, so the location is

C:\MyProgramData\chocolatey\lib\nodejs.commandline.0.10.31\tools\node_modules

C:\MyProgramData\ is chocolatey repo location.

查看更多
只若初见
7楼-- · 2019-01-01 05:01

In earlier versions of NPM modules were always placed in /usr/local/lib/node or wherever you specified the npm root within the .npmrc file. However, in NPM 1.0+ modules are installed in two places. You can have modules installed local to your application in /.node_modules or you can have them installed globally which will use the above.

More information can be found at https://github.com/isaacs/npm/blob/master/doc/install.md

查看更多
登录 后发表回答