-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 package@version uses incorrect installed version in npx 7 #3210
Comments
I can not duplicate this. When I run those commands my project has angular 12 ~/D/n/a/asdf (master|✔) $ npm ls
[email protected] /Users/wraithgar/Development/npm/ar/asdf
├── @angular-devkit/[email protected]
├── @angular/[email protected]
├── @angular/[email protected] I even tried it while having |
i tried again now, it's the same
|
What does |
|
I think I came across a similar (same?) issue:
Summary:
|
@rfgamaral Thanks for the additional report. I believe this is the same issue and I'm going to update the title of this issue to track it as such. |
Looks like a globally installed package breaks calling via npx, since it has a higher priority. Simple reproduction for [email protected]
|
Note that this does not only apply to globally installed packages, but also local ones: Reproduction commands:
And my result with npx
Note how the second There is no global
|
A comment on the severity of this: |
Thanks for the detailed reproduction and re-surfacing this issue @janpio. I've updgraded the severity of this and our team is currently working through all the Priority 1 bugs, so we can get some resolution to this. |
Hi, just wanting to provide a bug report that I am also running into this. Interestingly I see things like the following: $npx serverless@3 deploy Need to install the following packages: $npx serverless@3 --version So it seems to install the right package somewhere, but doesn't use it when running commands. |
Possibly closed by #4929. @lukekarrys will investigate and respond accordingly. |
I confirm it's working now |
Oh hey thanks for confirming @robertIsaac! |
For me, [email protected] continues to yield different results: C:\...\test>npx --version C:\...\test>npm ls svgo C:\...\test>npm ls svgo -g C:\...\test>npx [email protected] --version C:\...\test>npm i svgo@1 -g To address all issues (including breaking changes), run: Run C:\...\test>npx [email protected] --version C:\...\test>npm i [email protected] C:\...\test>npx [email protected] --version C:\...\test>npm exec [email protected] -- cmd /C "WHERE svgo" |
Slightly different on Linux, but still broken: $ npx --version
8.13.1
$ npm ls svgo
/home/node/project
`-- (empty)
$ npm ls svgo -g
/usr/local/lib
`-- (empty)
$ npx [email protected] --version
Need to install the following packages:
[email protected]
Ok to proceed? (y)
2.5.0
$ npm i svgo@1 -g
…
$ npx [email protected] --version
2.5.0
$ npm i [email protected]
…
$ npx [email protected] --version
2.7.0
$ npm exec [email protected] -- which -a svgo
/home/node/project/node_modules/.bin/svgo
/home/node/.npm/_npx/ef55ecbce75e2283/node_modules/.bin/svgo
/usr/local/bin/svgo
|
I will reopen as per @Khyalis and @andersk comments is by any chance you are using nvm? |
@robertIsaac nvm, or nvm-windows (a different project)? |
@robertIsaac I did not use nvm. Here’s a fully reproducible test case as a FROM node:18.4.0-alpine
WORKDIR /project
RUN set -ex; \
npm install --silent -g [email protected]; \
npm --version; \
version=$(npx -y [email protected] --version); \
test "$version" = 2.5.0; \
npm install --silent -g svgo@1; \
npm install --silent [email protected]; \
npm exec --silent -y [email protected] -- which -a svgo; \
version=$(npx -y [email protected] --version); \
test "$version" = 2.5.0 # fails Output$ docker build .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM node:18.4.0-alpine
---> 515db77e67c7
Step 2/3 : WORKDIR /project
---> Using cache
---> 718128102edc
Step 3/3 : RUN set -ex; npm install --silent -g [email protected]; npm --version; version=$(npx -y [email protected] --version); test "$version" = 2.5.0; npm install --silent -g svgo@1; npm install --silent [email protected]; npm exec --silent -y [email protected] -- which -a svgo; version=$(npx -y [email protected] --version); test "$version" = 2.5.0 # fails
---> Running in ff01e030000b
+ npm install --silent -g [email protected]
+ npm --version
8.13.1
+ npx -y [email protected] --version
npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
+ version=2.5.0
+ test 2.5.0 '=' 2.5.0
+ npm install --silent -g svgo@1
+ npm install --silent [email protected]
+ npm exec --silent -y '[email protected]' -- which -a svgo
/project/node_modules/.bin/svgo
/root/.npm/_npx/ef55ecbce75e2283/node_modules/.bin/svgo
/usr/local/bin/svgo
+ npx -y [email protected] --version
+ version=2.7.0
+ test 2.7.0 '=' 2.5.0
The command '/bin/sh -c set -ex; npm install --silent -g [email protected]; npm --version; version=$(npx -y [email protected] --version); test "$version" = 2.5.0; npm install --silent -g svgo@1; npm install --silent [email protected]; npm exec --silent -y [email protected] -- which -a svgo; version=$(npx -y [email protected] --version); test "$version" = 2.5.0 # fails' returned a non-zero code: 1 |
nvm, I have a mac |
@robertIsaac ah, gotcha, you mean that your system node was conflicting (also, what's |
Where tells you the exact location of a file
|
|
|
ah, fair enough, yes, i'm using bash. |
so what's the output of |
I use nvm and don’t have a system version, so it only prints out a single line. |
This should be fixed as of ~/D/n/s/npx $ npm i [email protected]
added 1 package, and audited 2 packages in 450ms
1 high severity vulnerability
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
~/D/n/s/npx $ npx [email protected] --version
json 9.0.5
written by Trent Mick
https://github.com/trentm/json |
This seems to have regressed for me: $ npx [email protected] --version
2.2.1
$ npm -v
8.19.2 |
@samboylett It looks like you are using an old npm version here (v8) I just tried on Node v20.6.0 (npm v9.8.1)
And it works as expected. |
actually looks like some weird data issue on my end: $ npx [email protected] --version
3.0.0
$ npx [email protected] --version
Need to install the following packages:
[email protected]
Ok to proceed? (y)
3.0.1
$ npx [email protected] --version
Need to install the following packages:
[email protected]
Ok to proceed? (y)
3.0.2
$ npx [email protected] --version
2.2.1
|
Current Behavior:
running
npx @package@version
generate it with the current install versionExpected Behavior:
it should be generated with the given version
Steps To Reproduce:
ex. steps to reproduce the behavior:
npm i -g npm@latest
to install npm 7npx @angular/cli@next new
Environment:
The text was updated successfully, but these errors were encountered: