this was created over in github a while back, but it doesn’t look like any action was taken on it
My operating system has created an invisible file inside one of my scope’s directories in my global module directory and this causes npm to throw a nasty error (and return non-zero) when trying to get a listing of installed modules.
Specifically, the command I’m running is:
npm ls --global --depth 0
This doesn’t happen when these files live inside the root of the global node_modules directory; only when they’re inside a scope’s directory.
In my opinion, at the least, npm should ignore invisible files in these directories. It appears that it does this for unscoped modules since .DS_Store files in those directories don’t throw any errors. It might also be good if npm would ignore anything that didn’t have a package.json in that directory since it’s not a valid module and should probably just be ignored. But I could see there being value in reporting busted modules in there, perhaps via a --strict flag or similar.
Relatedly, errors also get thrown for broken linked modules (ie: modules that were linked, but the target of the symlinks are no longer valid). I haven’t checked if this failure happens when
How can the CLI team reproduce the problem?
The quickest way to reproduce this problem is to touch a file inside a scope’s directory and run npm ls --global --depth 0 (paths sanitized):
$ npm ls --global --depth 0
├── error: ENOTDIR: not a directory, open path/to/global/node_modules/@testscope/.DS_Store/package.json
npm ERR! error in path/to/global/node_modules/@testscope/.DS_Store: ENOTDIR: not a directory, open ‘path/to/global/node_modules/@testscope/.DS_Store/package.json’
npm -v prints: 5.7.1
node -v prints: v8.9.4
npm config get registry prints: https://npm.mycompany.com/