Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Is NPM or the NPM update broken? #547

Closed
markusheiden opened this issue Oct 25, 2020 · 20 comments
Closed

Is NPM or the NPM update broken? #547

markusheiden opened this issue Oct 25, 2020 · 20 comments

Comments

@markusheiden
Copy link

What did you expect to happen?
NPM updated

What actually happened?
NPM ERR! global requires an add or rm option

Additional details:

  • macOS
  • topgrade and node/npm installed via homebrew.
  • Dry running: /usr/local/bin/npm update -g
―― 09:29:08 - Node Package Manager ―――――――――――――――――――――――――――――――――――――――――――――
 2020-10-25T08:29:08.002Z DEBUG topgrade::executor   > Running "/usr/local/bin/npm" "update" "-g"
npm ERR! global requires an add or rm option

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/markus/.npm/_logs/2020-10-25T08_29_08_266Z-debug.log
2020-10-25T08:29:08.290Z DEBUG topgrade::terminal > Desktop notification: npm failed

@r-darwish
Copy link
Owner

What happens if you manually run npm update -g?

@bingalls
Copy link

As of the recent release of Node v15 & Npm v7, npm update no longer accepts the -g global flag.

@r-darwish
Copy link
Owner

So what should be done instead?

@bingalls
Copy link

bingalls commented Oct 26, 2020 via email

@joschi
Copy link

joschi commented Oct 26, 2020

# topgrade -v --only node
 2020-10-26T09:20:36.864Z DEBUG topgrade::config > Configuration at /Users/joschi/.config/topgrade.toml
 2020-10-26T09:20:36.865Z DEBUG topgrade::config > Loaded configuration: ConfigFile { pre_commands: None, post_commands: None, commands: None, git_repos: None, predefined_git_repos: None, disable: None, ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, git_arguments: None, tmux_arguments: None, set_title: None, assume_yes: None, yay_arguments: None, no_retry: None, run_in_tmux: None, cleanup: None, notify_each_step: None, accept_all_windows_updates: None, only: None, composer: None, brew: None, linux: None, git: None, windows: None, vagrant: None }
 2020-10-26T09:20:36.865Z DEBUG topgrade         > Version: 5.8.1
 2020-10-26T09:20:36.865Z DEBUG topgrade         > OS: x86_64-apple-darwin
 2020-10-26T09:20:36.865Z DEBUG topgrade         > Args { inner: ["topgrade", "-v", "--only", "node"] }
 2020-10-26T09:20:36.865Z DEBUG topgrade         > Binary path: Ok("/usr/local/bin/topgrade")
 2020-10-26T09:20:36.865Z DEBUG topgrade         > Self Update: false
 2020-10-26T09:20:36.865Z DEBUG topgrade::utils  > Detected "/usr/local/bin/git" as "git"
 2020-10-26T09:20:36.865Z DEBUG topgrade::utils  > Detected "/usr/bin/sudo" as "sudo"
 2020-10-26T09:20:36.866Z DEBUG topgrade::utils  > Cannot find "pwsh"
 2020-10-26T09:20:36.867Z DEBUG topgrade::utils  > Cannot find "powershell"
 2020-10-26T09:20:36.867Z DEBUG topgrade::utils  > Path "/Users/joschi/.config/emacs" doesn't exist
 2020-10-26T09:20:36.867Z DEBUG topgrade::utils  > Path "/Users/joschi/.emacs.d" doesn't exist
 2020-10-26T09:20:36.867Z DEBUG topgrade::steps::git > /Users/joschi/.zshrc is a file. Checking /Users/joschi
 2020-10-26T09:20:36.867Z DEBUG topgrade::steps::git > Checking if /Users/joschi is a git repository
 2020-10-26T09:20:36.873Z TRACE topgrade::executor   > Output of "/usr/local/bin/git" "rev-parse" "--show-toplevel": Output { status: ExitStatus(ExitStatus(32768)), stdout: "", stderr: "fatal: Kein Git-Repository (oder irgendeines der Elternverzeichnisse): .git\n" }
 2020-10-26T09:20:36.873Z DEBUG topgrade::steps::git > /Users/joschi/.config/fish does not exists
 2020-10-26T09:20:36.873Z DEBUG topgrade::steps::git > /Users/joschi/Library/Application Support/openbox does not exists
 2020-10-26T09:20:36.873Z DEBUG topgrade::steps::git > /Users/joschi/Library/Application Support/bspwm does not exists
 2020-10-26T09:20:36.873Z DEBUG topgrade::steps::git > /Users/joschi/Library/Application Support/i3 does not exists
 2020-10-26T09:20:36.873Z DEBUG topgrade::steps::git > /Users/joschi/Library/Application Support/sway does not exists
 2020-10-26T09:20:36.873Z DEBUG topgrade::runner     > Step "npm"
 2020-10-26T09:20:36.873Z DEBUG topgrade::utils      > Detected "/usr/local/bin/npm" as "npm"

―― 10:20:36 - Node Package Manager ―――――――――――――――――――――――――――――――――――――――――――――
 2020-10-26T09:20:36.874Z DEBUG topgrade::executor   > Running "/usr/local/bin/npm" "update" "-g"
npm ERR! global requires an add or rm option

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/joschi/.npm/_logs/2020-10-26T09_20_37_159Z-debug.log
 2020-10-26T09:20:37.182Z DEBUG topgrade::terminal   > Desktop notification: npm failed

Retry? (y)es/(N)o/(s)hell
 2020-10-26T09:20:39.412Z DEBUG topgrade::runner     > Step "yarn"
 2020-10-26T09:20:39.412Z DEBUG topgrade::utils      > Detected "/usr/local/bin/yarn" as "yarn"
 2020-10-26T09:20:39.580Z TRACE topgrade::executor   > Output of "/usr/local/bin/yarn" "--version": Output { status: ExitStatus(ExitStatus(0)), stdout: "1.22.10\n", stderr: "" }

―― 10:20:39 - Yarn ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
 2020-10-26T09:20:39.580Z DEBUG topgrade::executor   > Running "/usr/local/bin/yarn" "global" "upgrade" "-s"

―― 10:20:39 - Summary ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
npm: FAILED
yarn: OK

npm debug log file:

0 verbose cli [
0 verbose cli   '/usr/local/Cellar/node/15.0.1/bin/node',
0 verbose cli   '/usr/local/bin/npm',
0 verbose cli   'update',
0 verbose cli   '-g'
0 verbose cli ]
1 info using npm@7.0.3
2 info using node@v15.0.1
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 0ms
8 timing config:load:project Completed in 1ms
9 timing config:load:file:/Users/joschi/.npmrc Completed in 0ms
10 timing config:load:user Completed in 0ms
11 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
12 timing config:load:global Completed in 0ms
13 timing config:load:cafile Completed in 0ms
14 timing config:load:validate Completed in 0ms
15 timing config:load:setUserAgent Completed in 1ms
16 timing config:load:setEnvs Completed in 0ms
17 timing config:load Completed in 5ms
18 verbose npm-session cc73ee8ab927eb5f
19 timing npm:load Completed in 11ms
20 http fetch GET 200 https://registry.npmjs.org/npm 175ms
21 timing arborist:ctor Completed in 0ms
22 timing command:update Completed in 1ms
23 verbose stack Error: global requires an add or rm option
23 verbose stack     at Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:185:29)
23 verbose stack     at Arborist.[loadTrees] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:186:17)
23 verbose stack     at Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:121:27)
23 verbose stack     at update (/usr/local/lib/node_modules/npm/lib/update.js:34:13)
23 verbose stack     at cmd (/usr/local/lib/node_modules/npm/lib/update.js:15:27)
23 verbose stack     at Object.[_runCmd] (/usr/local/lib/node_modules/npm/lib/npm.js:112:7)
23 verbose stack     at fn (/usr/local/lib/node_modules/npm/lib/npm.js:46:40)
23 verbose stack     at Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/cli.js:56:7)
24 verbose cwd /Users/joschi
25 verbose Darwin 19.6.0
26 verbose argv "/usr/local/Cellar/node/15.0.1/bin/node" "/usr/local/bin/npm" "update" "-g"
27 verbose node v15.0.1
28 verbose npm  v7.0.3
29 error global requires an add or rm option
30 verbose exit 1

@r-darwish
Copy link
Owner

Can you guys just run npm up and see if it does what it should? If so, I'll make a patch that skips -g with NPM >7

@joschi
Copy link

joschi commented Oct 26, 2020

@r-darwish There still seem to be some issues regarding npm 7's new update behavior.

At least on my system (macOS, npm 7.0.3), npm up does not update globally installed packages.

npm/cli#1962
npm/cli#2002

@r-darwish
Copy link
Owner

I don't feel like watching NPM tickets so whenever a solution comes out I'll be happy if someone writes it here.

@jsejcksn
Copy link

I don't feel like watching NPM tickets

@r-darwish

Here's the issue: npm/cli#1962

It's easy to get only the kind of notification you want:

In the issue details area:

notifications

notification-settings

@r-darwish
Copy link
Owner

I don't feel like watching NPM tickets

@r-darwish

Here's the issue: npm/cli#1962

It's easy to get only the kind of notification you want:

In the issue details area:

notifications notification-settings

Nice tip. Thanks

@bingalls
Copy link

bingalls commented Nov 5, 2020

Solution: mitigate this on Mac OSX, until Node fixes v15, with the following

brew install nvm
nvm install 14.15.0
nvm alias default stable
nvm use default

To restore topgrade to the latest node version, once it is fixed, run nvm use system
NVM Node Version Manager has competing Homebrew packages, but I am not familiar with their syntax.

@REBELinBLUE
Copy link

Um that isn't really fixing it though that is just changing your system wide version of node to 14.15, surely a better option would just be to add disable = ["node"] to topgrade.toml for now

@ghost
Copy link

ghost commented Nov 8, 2020

I suggest deprecating node/npm. Also acceptable to me would be to keep the current behavior but guard it with an npm -v check. If the npm version is < 7, run npm update -g; otherwise, do nothing with node/npm.

@narfk
Copy link

narfk commented Nov 11, 2020

The new version solves the problem
npm -g install npm@7.0.10

@r-darwish
Copy link
Owner

So this issue can be closed?

@narfk
Copy link

narfk commented Nov 11, 2020

maybe someone else could confirm that?
otherwise, yes

@jrgarcia
Copy link
Contributor

@narfk @r-darwish Upgrading to npm 7.0.10 worked for me as well!

@ZepDonald
Copy link

I upgraded node from 15.1.0 to 15.2.0 and it's working for me now.

@joschi
Copy link

joschi commented Nov 12, 2020

I can confirm that it's working with the latest version of npm.

# npm -v
7.0.10
# topgrade --only node -v
 2020-11-12T07:15:23.877Z DEBUG topgrade::config > Configuration at /Users/joschi/.config/topgrade.toml
 2020-11-12T07:15:23.877Z DEBUG topgrade::config > Loaded configuration: ConfigFile { pre_commands: None, post_commands: None, commands: None, git_repos: None, predefined_git_repos: None, disable: None, ignore_failures: None, remote_topgrades: None, remote_topgrade_path: None, ssh_arguments: None, git_arguments: None, tmux_arguments: None, set_title: None, assume_yes: None, yay_arguments: None, no_retry: None, run_in_tmux: None, cleanup: None, notify_each_step: None, accept_all_windows_updates: None, only: None, composer: None, brew: None, linux: None, git: None, windows: None, vagrant: None }
 2020-11-12T07:15:23.877Z DEBUG topgrade         > Version: 5.9.1
 2020-11-12T07:15:23.877Z DEBUG topgrade         > OS: x86_64-apple-darwin
 2020-11-12T07:15:23.877Z DEBUG topgrade         > Args { inner: ["topgrade", "--only", "node", "-v"] }
 2020-11-12T07:15:23.878Z DEBUG topgrade         > Binary path: Ok("/usr/local/bin/topgrade")
 2020-11-12T07:15:23.878Z DEBUG topgrade         > Self Update: false
 2020-11-12T07:15:23.878Z DEBUG topgrade::utils  > Detected "/usr/local/bin/git" as "git"
 2020-11-12T07:15:23.878Z DEBUG topgrade::utils  > Detected "/usr/bin/sudo" as "sudo"
 2020-11-12T07:15:23.878Z DEBUG topgrade::utils  > Cannot find "pwsh"
 2020-11-12T07:15:23.878Z DEBUG topgrade::utils  > Cannot find "powershell"
 2020-11-12T07:15:23.878Z DEBUG topgrade::utils  > Path "/Users/joschi/.config/emacs" doesn't exist
 2020-11-12T07:15:23.878Z DEBUG topgrade::utils  > Path "/Users/joschi/.emacs.d" doesn't exist
 2020-11-12T07:15:23.878Z DEBUG topgrade::steps::git > /Users/joschi/.zshrc is a file. Checking /Users/joschi
 2020-11-12T07:15:23.878Z DEBUG topgrade::steps::git > Checking if /Users/joschi is a git repository
 2020-11-12T07:15:23.882Z TRACE topgrade::executor   > Output of "/usr/local/bin/git" "rev-parse" "--show-toplevel": Output { status: ExitStatus(ExitStatus(32768)), stdout: "", stderr: "fatal: Kein Git-Repository (oder irgendeines der Elternverzeichnisse): .git\n" }
 2020-11-12T07:15:23.882Z DEBUG topgrade::steps::git > /Users/joschi/.config/fish does not exists
 2020-11-12T07:15:23.882Z DEBUG topgrade::steps::git > /Users/joschi/Library/Application Support/openbox does not exists
 2020-11-12T07:15:23.882Z DEBUG topgrade::steps::git > /Users/joschi/Library/Application Support/bspwm does not exists
 2020-11-12T07:15:23.883Z DEBUG topgrade::steps::git > /Users/joschi/Library/Application Support/i3 does not exists
 2020-11-12T07:15:23.883Z DEBUG topgrade::steps::git > /Users/joschi/Library/Application Support/sway does not exists
 2020-11-12T07:15:23.883Z DEBUG topgrade::runner     > Step "npm"
 2020-11-12T07:15:23.883Z DEBUG topgrade::utils      > Detected "/usr/local/bin/npm" as "npm"

―― 08:15:23 - Node Package Manager ―――――――――――――――――――――――――――――――――――――――――――――
 2020-11-12T07:15:23.883Z DEBUG topgrade::executor   > Running "/usr/local/bin/npm" "update" "-g"

added 65 packages, and audited 498 packages in 4s

12 packages are looking for funding
  run `npm fund` for details

2 low severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
 2020-11-12T07:15:28.199Z DEBUG topgrade::runner     > Step "yarn"

―― 08:15:28 - Summary ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
npm: OK
yarn: SKIPPED: Cannot find "yarn" in PATH
 2020-11-12T07:15:28.200Z DEBUG topgrade::terminal   > Desktop notification: Topgrade finished sucessfully

@r-darwish
Copy link
Owner

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants