Can someone tell me where can I find the Node.js modules, which I installed using npm
?
From the docs:
Packages are dropped into the node_modules folder under the prefix. When installing locally, this means that you can require("packagename") to load its main module, or require("packagename/lib/path/to/sub/module") to load other modules.
Global installs on Unix systems go to {prefix}/lib/node_modules. Global installs on Windows go to {prefix}/node_modules (that is, no lib folder.)
Scoped packages are installed the same way, except they are grouped together in a sub-folder of the relevant node_modules folder with the name of that scope prefix by the @ symbol, e.g. npm install @myorg/package would place the package in {prefix}/node_modules/@myorg/package. See scope for more details.
If you wish to require() a package, then install it locally.
You can get your {prefix}
with npm config get prefix
. (Useful when you installed node with nvm).
Read about locally.
Read about globally.
In Ubuntu 14.04 they are installed at
/usr/lib/node_modules
As the other answers say, the best way is to do
npm list -g
However, if you have a large number of npm
packages installed, the output of this command could be very long and a big pain to scroll up (sometimes it's not even possible to scroll that far back).
In this case, pipe the output to the more
program, like this
npm list -g | more
If a module was installed with the global (-g
) flag, you can get the parent location by running:
npm get prefix
or
npm ls -g --depth=0
which will print the location along with the list of installed modules.
Btw, npm will look for node_modules in parent folders (up to very root) if can not find in local.
Echo the config: npm config ls
or npm config list
Show all the config settings: npm config ls -l
or npm config ls --json
Print the effective node_modules folder: npm root
or npm root -g
Print the local prefix: npm prefix
or npm prefix -g
(This is the closest parent directory to contain a package.json file or node_modules directory)