`npx --version` reports incorrect version
PatrickLehnerXI opened this issue · comments
Versions
OS: Windows 10 (Version 10.0.15063)
Node: v10.5.0
npm: 6.1.0 (installed via npm i -g npm@latest
)
npx: 10.2.0 (installed via npm i -g npx@latest
)
libnpx: 10.2.0
Bug information:
- expected behavior:
npx -v
reports "10.2.0" - actual behavior:
npx -v
reports "6.1.0" (note: that's npm's version) - reproduction steps:
- on a Windows without Node or global npm modules (i.e. no
%APPDATA%\npm
folder), install Node 10.5 npm i -g npm@latest
npm i -g npx@latest
- on a Windows without Node or global npm modules (i.e. no
Honorable Mention
- @saschanaz mentioning this in npm/npm#20580 (in this comment) saved me some more hours tracing this discrepancy (and my sanity)
Just noticed: possibly caused by the changes in npm/npm#19608 ?
@PatrickLehnerXI what happens if you run where npx
?
@szarouski
C:\Users\patrick.lehner>where npx
C:\Program Files\nodejs\npx
C:\Program Files\nodejs\npx.cmd
C:\Users\patrick.lehner\AppData\Roaming\npm\npx
C:\Users\patrick.lehner\AppData\Roaming\npm\npx.cmd
Just to make sure, i updated npx
and it still yields the same incorrect version number with npm 6.4.1:
C:\Users\patrick.lehner>npm i -g npx@latest
npm WARN rm not removing C:\Users\patrick.lehner\AppData\Roaming\npm\npx.cmd as it wasn't installed by C:\Users\patrick.lehner\AppData\Roaming\npm\node_modules\npx
npm WARN rm not removing C:\Users\patrick.lehner\AppData\Roaming\npm\npx as it wasn't installed by C:\Users\patrick.lehner\AppData\Roaming\npm\node_modules\npx
C:\Users\patrick.lehner\AppData\Roaming\npm\npx -> C:\Users\patrick.lehner\AppData\Roaming\npm\node_modules\npx\index.js
+ npx@10.2.0
updated 1 package in 18.473s
C:\Users\patrick.lehner>npx -v
6.4.1
@PatrickLehnerXI that is because it updates C:\Users\patrick.lehner\AppData\Roaming\npm\npx & not C:\Program Files\nodejs\npx . It is a bit annoying, but there must be a way to fix that.
Indeed.
I guess one way would be that the npx installed with Node should check if a (newer) npx is installed to %appdata%
, and use that instead