-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
Current Behavior:
npm ls fails (non-zero exit code, ELSPROBLEMS JSON error code) if there are extraneous packages. This is a behavior change from npm v6; see steps to reproduce below.
Extraneous packages can happen if package.json is deleted, or if npm v6 is used to install packages in an empty directory.
This issue matters to me because of the way Etherpad handles plugin packages: They are installed in a separate directory without a package.json, and npm ls is expected to successfully discover them.
Expected Behavior:
npm ls should not fail if there are extraneous packages, or at least there should be an option to not fail due to extraneous packages. Note that npm ls includes extraneous packages in its output, and it marks those packages as extraneous, so extraneous packages do not seem to be a problem worthy of a fatal error from npm ls.
Steps To Reproduce:
v6=$(mktemp -d) && echo "v6=$v6" && (cd "$v6" && npm i npm@^6.0.0)
v7=$(mktemp -d) && echo "v7=$v7" && (cd "$v7" && npm i npm@^7.0.0)
npmv6() { "$v6"/node_modules/.bin/npm "$@"; }
npmv7() { "$v7"/node_modules/.bin/npm "$@"; }
tmp=$(mktemp -d) && cd "$tmp"
npmv6 i npm-dummy-package
npmv6 ls --silent >/dev/null && echo "v6 success" || echo "v6 failure" # prints "v6 success"
npmv7 ls --silent >/dev/null && echo "v7 success" || echo "v7 failure" # prints "v7 failure"
rm -rf "$v6" "$v7" "$tmp"Environment:
- OS: Ubuntu 20.04
- Node: 14.15.4
- npm: 7.5.3