Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm ls fails if there are extraneous packages #2664

Closed
rhansen opened this issue Feb 10, 2021 · 4 comments
Closed

[BUG] npm ls fails if there are extraneous packages #2664

rhansen opened this issue Feb 10, 2021 · 4 comments
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release

Comments

@rhansen
Copy link

rhansen commented Feb 10, 2021

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
@rhansen rhansen added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Feb 10, 2021
@ljharb
Copy link
Contributor

ljharb commented Feb 10, 2021

Extra deps certainly shouldn't fail npm ls; the dep graph is only invalid with missing or invalid deps.

@darcyclarke
Copy link
Contributor

@rhansen appreciate you filing this, we've got some ideas on how to improve this & will post back with updates soon.

@glen-84
Copy link

glen-84 commented Apr 23, 2021

@nlf Should this be closed? (42ca59e)

@nlf
Copy link
Contributor

nlf commented Apr 23, 2021

yes it should, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

5 participants