nvm: npm does not list globally installed modules
Hi,
npm list -g
is not showing globally installed modules:
# adam.moss@scarecrow:~ $ npm list -g
/Users/adam.moss/.nvm/versions/node/v7.2.1/lib
└── (empty)
However there are modules installed (inc. npm
itself, obviously 😃)
# adam.moss@scarecrow:~ $ ls .nvm/versions/node/v7.2.1/lib/node_modules/
total 0
drwxr-xr-x 10 adam.moss staff 340B 7 Dec 14:07 .
drwxr-xr-x 4 adam.moss staff 136B 6 Dec 21:48 ..
drwxr-xr-x 12 adam.moss staff 408B 7 Dec 14:07 gulp-cli
drwxr-xr-x 9 adam.moss staff 306B 7 Dec 14:07 istanbul
drwxr-xr-x 10 adam.moss staff 340B 7 Dec 14:07 jasmine
drwxr-xr-x 15 adam.moss staff 510B 7 Dec 14:07 mocha
drwxr-xr-x 27 adam.moss staff 918B 7 Dec 14:07 npm
drwxr-xr-x 21 adam.moss staff 714B 7 Dec 14:07 pm2
drwxr-xr-x 6 adam.moss staff 204B 7 Dec 14:07 react-native-cli
drwxr-xr-x 21 adam.moss staff 714B 7 Dec 14:07 snyk
Debug output
# adam.moss@scarecrow:~ $ nvm debug
nvm --version: v0.32.1
$SHELL: /usr/local/bin/bash
$HOME: /Users/adam.moss
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
nvm current: v7.2.1
which node: $NVM_DIR/versions/node/v7.2.1/bin/node
which iojs:
which npm: $NVM_DIR/versions/node/v7.2.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v7.2.1
npm root -g: $NVM_DIR/versions/node/v7.2.1/lib/node_modules
And npm outdated -g
does actually work
# adam.moss@scarecrow:~ $ npm outdated -g
Package Current Wanted Latest Location
npm 3.10.10 3.10.10 4.0.3
Contents of my .npmrc
save-exact=true
This is on macOS Sierra (v10.12.1)
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (9 by maintainers)
@vitaly-t the command is
npm list -g --depth=0
- note the double dashes.See https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders .
For me, this solved it:
However, I think this should be solved within NVM properly.
Actually after some more digging I think this is a
npm
bug. I haveNODE_ENV=production
in my environment. If I remove that it works as expected. So digging throughls.js
in npm itself it appears something is going wrong between lines 133 and 145.@ljharb oh, stupid me,…thanks so much for pointing out at the obvious, I was being blind, it seems, it does indeed work that way.
OK Thanks.