I am looking for a command that will list the names of global modules that I have npm link
\'d to local copies, also listing the local path.
In fact, a list
If you want a nice colored output from npm list
, you may like:
\ls -F node_modules | sed -n 's/@$//p' | xargs npm ls -g --depth 0
which gives in my current playground dir:
+-- color@0.11.1
+-- grunt@0.4.5
+-- http-server@0.8.5
+-- jsdom@8.0.2
+-- jsonfile@2.2.3
+-- underscore@1.8.3
+-- xmlserializer@0.3.3
`-- zombie@4.2.1
It makes a few assumptions but it should work in most cases, or be easy to adapt with the explanations below.
\ls
to bypass possible aliases on your ls
command-F
option adds an '@' indicator for linkssed
command selects those links and removes the indicatorxargs
part passes previous output as arguments to npm ...
npm
is invoked with
list
or ls
to list modules with versions
ll
to get details about each listed module.-g
for the global modules and--depth 0
for a shallow listing (optional)--long false
(default with 'list'). Issue: for some reason npm gives extraneous entries for me at the moment (non colored). They would be those I had "npm unlink"ed.
For "a list of all globally installed modules" in current npm path, you just do
npm list -g
For further needs you may want to have a look at
npm help folders
You cannot follow symlinks backwards unless you scan your whole filesystem and (then that's not a npm specific question).
For quickly finding files and directories by name, I use locate
which works on an index rebuilt usually once a day.
locate '*/node_modules'
and start working from there (you may want to refine the search with --regexp
option.