Where does npm install packages?

后端 未结 23 1627
梦毁少年i
梦毁少年i 2020-11-22 06:03

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

23条回答
  •  没有蜡笔的小新
    2020-11-22 06:23

    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 or use npm config set prefix /my/npm/global/modules/prefix.

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

提交回复
热议问题