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] npx uses local package when another version is requested #3776

Closed
1 task done
Maxim-Mazurok opened this issue Sep 20, 2021 · 1 comment
Closed
1 task done
Labels
Bug thing that needs fixing Duplicate duplicate of another, existing issue Release 7.x work is associated with a specific npm 7 release

Comments

@Maxim-Mazurok
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I have prettier-plugin-packagejson installed (which has sort-package-json@1.51.0 as a dependency)

And trying to run npx sort-package-json@1.48 because I want to use version 1.48, before this tragic PR was merged

But npx picks up version 1.51.0 which is in my local deps, and in PATH. But it's the wrong version.

Expected Behavior

npx should make sure that it's running version 1.48, as requested.

Steps To Reproduce

  1. Make sure sort-package-json is not installed globally (npm rm sort-package-json)
  2. Make sure it's not in PATH: which sort-package-json should not return anything
  3. Do npm init
  4. Add these two scripts in package.json:
    "z": "should be last",
    "a": "should be first"
    
  5. Do npm i prettier-plugin-packagejson
  6. Run npx sort-package-json@1.48
  7. Observe scripts still not sorted, because 1.51 was used (cat package.json, see "z" will be still before "a")

Optional:

  1. Remove local deps: rm -rf ./node_modules/
  2. Run npx sort-package-json@1.48 again
  3. Observe scripts are now sorted because 1.48 was used (cat package.json, see "a" will be before "z")

Environment

  • OS: Ubuntu 20 (WSL)
  • Node: 16.7.0
  • npm: 7.19.0
@Maxim-Mazurok Maxim-Mazurok 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 Sep 20, 2021
@lukekarrys
Copy link
Contributor

Thanks for the thorough report @Maxim-Mazurok. I've confirmed this is also an issue on the latest npm v7.24.0. I believe this is a duplicate of #3210, so I'm going to close this and use that as the issue to track.

@lukekarrys lukekarrys added Duplicate duplicate of another, existing issue and removed Needs Triage needs review for next steps labels Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Duplicate duplicate of another, existing issue Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

No branches or pull requests

2 participants