zkat / npx

execute npm package binaries (moved)

Home Page:https://github.com/npm/npx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`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

Honorable Mention

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