Easy way to list node modules I have npm linked?
To list all globally linked modules, this works (documentation https://docs.npmjs.com/cli/ls):
npm ls -g --depth=0 --link=true
I had to update the version of npm on my machine first, though:
npm install npm@latest -g
Did you try just listing the node_modules
directory contents (e.g. ls -l node_modules | grep ^l
)? They're normal symlinks.
If you really need to find all symlinks, you could try something like find / -type d -name "node_modules" 2>/dev/null | xargs -I{} find {} -type l -maxdepth 1 | xargs ls -l
.
A better alternative to parsing ls
is to use find
like this:
find . -type l
You can use -maxdepth 1
to only process the first directory level:
find . -maxdepth 1 -type l
You can use -ls
for additional info.
For instance, for finding node modules that are npm linked:
find node_modules -maxdepth 1 -type l -ls
Here's an article why parsing ls
is not the best idea