Can someone tell me where can I find the Node.js modules, which I installed using npm
?
If you have Visual Studio installed, you will find it comes with its own copy of node separate from the one that is on the path when you installed node yourself - Mine is in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\NodeJs.
If you run the npm command from inside this directory you will find out which node modules are installed inside visual studio.
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.
$ npm root -g
/usr/local/lib/node_modules
See the documentation.
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.
To get a compact list without dependencies simply use
npm list -g --depth 0
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.
Windows 10: When I ran npm prefix -g
, I noticed that the install location was inside of the git shell's path that I used to install. Even when that location was added to the path, the command from the globally installed package would not be recognized. Fixed by:
npm config edit