npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.18k stars 2.98k forks source link

[BUG] npm outdated does not list global installed packages #6098

Open ItsIgnacioPortal opened 1 year ago

ItsIgnacioPortal commented 1 year ago

Is there an existing issue for this?

This issue exists in the latest npm version

Current Behavior

I have installed calculator@0.1.11 globally by running npm install -g calculator@0.1.11. Running npm help outdated shows me the documentation, which lists global as a valid option. So I tried to run:

npm outdated -g

But it outputs nothing. Running all the possible variations:

npm outdated -g

npm outdated --global

npm outdated global

None of them give any output. I expected to see the available upgrade to calculator@0.1.12

Expected Behavior

npm outdated -g
Package     Current  Wanted  Latest  Location                 Depended by
calculator   0.1.11  0.1.12  0.1.12  node_modules/calculator  User

Steps To Reproduce

  1. npm install -g calculator@0.1.11
  2. npm outdated -g

Environment

I installed node through nvm 1.1.9

ljharb commented 1 year ago

imo npm outdated -g doesn't really make sense, since there's no global package.json.

ItsIgnacioPortal commented 1 year ago

imo npm outdated -g doesn't really make sense, since there's no global package.json.

The objective of running npm-outdated for global packages is to check if we have the latest version available. Otherwise there is no easy way of checking for updates. This should be supported

wraithgar commented 1 year ago

I can't reproduce this.

$ npm i -g calculator@0.1.11

added 76 packages, and audited 77 packages in 2s

found 0 vulnerabilities
~/D/n/c/b/main (latest|✔) $ npm outdated -g
Package     Current  Wanted  Latest  Location                 Depended by
calculator   0.1.11  0.1.12  0.1.12  node_modules/calculator  global
~/D/n/c/b/main (latest|✔) $ npm -v
8.19.3

Are you using nvs by chance? https://github.com/jasongin/nvs/issues/252

ItsIgnacioPortal commented 1 year ago

I can't reproduce this.

$ npm i -g calculator@0.1.11

added 76 packages, and audited 77 packages in 2s

found 0 vulnerabilities
~/D/n/c/b/main (latest|✔) $ npm outdated -g
Package     Current  Wanted  Latest  Location                 Depended by
calculator   0.1.11  0.1.12  0.1.12  node_modules/calculator  global
~/D/n/c/b/main (latest|✔) $ npm -v
8.19.3

Are you using nvs by chance? jasongin/nvs#252

Nope. I never installed nvs. I'm using nvm. I'm on windows though. You seem to be on linux

ljharb commented 1 year ago

nvm-windows, or actual nvm?

ItsIgnacioPortal commented 1 year ago

nvm-windows, or actual nvm?

nvm-windows

bestpika commented 1 year ago

I have a similar problem. I used nvm-windows and installed node v18.9.0 and npm v9.4.0. image Also, this problem has already happened with npm v8.x. By the way, nvs also has this problem.

jerone commented 1 year ago

I'm having the same issue.

As part of https://github.com/q-nick/npm-gui/issues/89 I tried to research a little. These are my findings:

Nodejs version v18.11.0.

NPM version 9.4.1.

I also have nvm-windows installed. Version 1.1.10.

Weirdly enough, npm-check-updates does detect updates correctly.

npm outdated -g --all does execute the outdated check, but also for dependencies of dependencies (because that's what --all does). Sadly npm outdated -g --all --depth=0 did not change the huge list.

npm ls -g --depth=0 does detect all global installed packages correctly.

Click here to see output from npm ls -g --depth=0 --json. ```json { "resolved": "file:../Users//AppData/Roaming/nvm/v18.11.0", "dependencies": { "@angular/cli": { "version": "15.0.5", "overridden": false }, "@cspell/dict-nl-nl": { "version": "2.2.8", "overridden": false }, "corepack": { "version": "0.15.3", "overridden": false }, "cspell": { "version": "6.18.1", "overridden": false }, "generator-code": { "version": "1.7.2", "overridden": false }, "generator-eslint": { "version": "4.1.1", "overridden": false }, "generator-jest": { "version": "1.8.0", "overridden": false }, "generator-sublime": { "version": "2.0.13", "overridden": false }, "js-to-ts-converter": { "version": "0.18.2", "overridden": false }, "np": { "version": "7.6.3", "overridden": false }, "npm-check-updates": { "version": "16.6.2", "overridden": false }, "npm-gui": { "version": "4.0.3", "overridden": false }, "npm": { "version": "9.2.0", "overridden": false }, "web-ext": { "version": "7.4.0", "overridden": false }, "yarn": { "version": "1.22.19", "overridden": false }, "yo": { "version": "4.3.1", "overridden": false } } } ```

My suspicion is that resolved property is not correctly handled in npm outdated -g.

segevfiner commented 1 month ago

Happens to me with nvm-windows and fnm on Windows 11.

On Node.js 20.14.0, fnm 1.37, npm 10.8.1