Where does npm install packages?

后端 未结 23 1370
梦毁少年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:40

    Not direct answer but may help ....

    The npm also has a cache folder, which can be found by running npm config get cache (%AppData%/npm-cache on Windows).

    The npm modules are first downloaded here and then copied to npm global folder (%AppData%/Roaming/npm on Windows) or project specific folder (your-project/node_modules).

    So if you want to track npm packages, and some how, the list of all downloaded npm packages (if the npm cache is not cleaned) have a look at this folder. The folder structure is as {cache}/{name}/{version}

    This may help also https://docs.npmjs.com/cli/cache

    0 讨论(0)
  • 2020-11-22 06:40

    From the docs:

    In npm 1.0, there are two ways to install things:

    • globally —- This drops modules in {prefix}/lib/node_modules, and puts executable files in {prefix}/bin, where {prefix} is usually something like /usr/local. It also installs man pages in {prefix}/share/man, if they’re supplied.

    • locally —- This installs your package in the current working directory. Node modules go in ./node_modules, executables go in ./node_modules/.bin/, and man pages aren’t installed at all.

    You can get your {prefix} with npm config get prefix. (Useful when you installed node with nvm).

    0 讨论(0)
  • 2020-11-22 06:42

    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
    
    0 讨论(0)
  • 2020-11-22 06:43

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

    0 讨论(0)
  • 2020-11-22 06:48

    Windows 7, 8 and 10 - %USERPROFILE%\AppData\Roaming\npm\node_modules.

    Note : If you are somewhere in folder type cd .. until you are in C: directory. Then, type cd %USERPROFILE%\AppData\Roaming\npm\node_modules. And, magically %USERPROFILE% will change into Users\YourUserProfile\. I just wanted to clarify on ideas referred by Decko in first response. npm list -g will list all the bits you got globally installed. If you need to find your project related npm package then cd 'your angular project xyz', then run npm list. It will show list of modules in npm package. It will also give you list of dependencies missing, and you may require to effectively run that project.

    0 讨论(0)
提交回复
热议问题