[BUG] npm login - Exit handler never called!
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
When trying to run npm loginto authenticate with my companies artifactory in order to run npm install, I am unable to login, and the following error message is shown
$ npm login npm notice Log in on https://artifactory.{companyname}.com/artifactory/api/npm/et-npm/ Login at: https://artifactory.{companydomain}/ui/auth-provider/npm?uuid={id} npm error Exit handler never called! npm error This is an error with npm itself. Please report this error at: npm error https://github.com/npm/cli/issues npm error A complete log of this run can be found in: D:\Users\etc
Expected Behavior
I am expecting to be logged in, or the web browser for our artifacory is prompted so that I am authenticated. Then I can npm install correctly
Steps To Reproduce
I cannot provide those details.
Environment
- npm: 10.8.1
- Node.js: 20.12.2
- OS Name: Windows
- System Model Name:
- npm config: I cannot provide those details
HI @DanielLey21
To better understand the issue, could you please provide your npm config details. Please make sure to mask any sensitive information. you can replace sensitive information by [MASKED] or ***.
This will help to reproduce the issue and investigate further.
Hi. :wave: In case it helps, I've been running into this too. Here's my details:
Configuration
init-author-name=Brooke Kuhlmann
init-license=Hippocratic-2.1
progress=false
save-prefix=~
//registry.npmjs.org/:_authToken=<redacted>
System
- OS: macOS 14.5
- Node: 22.4.1
- Browser: Firefox
The workaround I've found is not to hit ENTER when problem occurs but, instead, copy the URL and paste it directly into your browser. This seems to complete authentication properly. ...but if you do hit enter, you'll always get the error reported above.
@bkuhlmann Thanks for the npm config, ofcourse i have tried with similar config with npm registry and authToken. On npm login command on Press Enter key it successfully launched the npmjs browser with login page as expected. Please check your config registry and try again.
Tried on: OS: macOS 14.5 Node 20 and 22
Thanks. OK, I think I've got better Steps to Recreate for you. Try this:
Initial Configuration
init-author-name="Brooke Kuhlmann"
init-license="Hippocratic-2.1"
progress=false
save-prefix="~"
Steps
Notice I've made sure the registry is deleted this time. Now attempt to login via npm login. Here's what I see:
npm notice Log in on https://registry.npmjs.org/
Login at:
https://www.npmjs.com/login?next=/login/cli/<redacted>
Press ENTER to open in the browser...
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error <https://github.com/npm/cli/issues>
npm error A complete log of this run can be found in: /Users/bkuhlmann/.npm/_logs/2024-07-13T17_26_46_989Z-debug-0.log
Here's the full log:
Log Details
File: /Users/bkuhlmann/.npm/_logs/2024-07-13T17_26_46_989Z-debug-0.log
0 verbose cli /Users/bkuhlmann/.cache/fnm/node-versions/v22.4.1/installation/bin/node /Users/bkuhlmann/.local/state/fnm_multishells/1153_1720632845221/bin/npm
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:/Users/bkuhlmann/.cache/fnm/node-versions/v22.4.1/installation/lib/node_modules/npm/npmrc
4 silly config load:file:/Users/bkuhlmann/Engineering/OSS/dotfiles/.npmrc
5 silly config load:file:/Users/bkuhlmann/.npmrc
6 silly config load:file:/Users/bkuhlmann/.cache/fnm/node-versions/v22.4.1/installation/etc/npmrc
7 verbose title npm login
8 verbose argv "login"
9 verbose logfile logs-max:10 dir:/Users/bkuhlmann/.npm/_logs/2024-07-13T17_26_46_989Z-
10 verbose logfile /Users/bkuhlmann/.npm/_logs/2024-07-13T17_26_46_989Z-debug-0.log
11 notice Log in on https://registry.npmjs.org/
12 verbose web login before first POST
13 silly logfile start cleaning logs, removing 1 files
14 silly logfile done cleaning log files
15 http fetch POST 200 https://registry.npmjs.org/-/v1/login 1879ms
16 verbose web auth got response {
16 verbose web auth loginUrl: 'https://www.npmjs.com/login?next=/login/cli/<redacted>',
16 verbose web auth doneUrl: 'https://registry.npmjs.org/-/v1/done?sessionId=<redacted>'
16 verbose web auth }
17 verbose web auth opening url pair
18 http fetch GET 202 https://registry.npmjs.org/-/v1/done?sessionId=*** 207ms
19 verbose cwd /Users/bkuhlmann/Engineering/OSS/dotfiles
20 verbose os Darwin 23.5.0
21 verbose node v22.4.1
22 verbose npm v10.8.1
23 error Exit handler never called!
24 error This is an error with npm itself. Please report this error at:
25 error <https://github.com/npm/cli/issues>
26 verbose exit 0
27 info ok
28 error A complete log of this run can be found in: /Users/bkuhlmann/.npm/_logs/2024-07-13T17_26_46_989Z-debug-0.log
So the above errors and I don't see //registry.npmjs.org/:_authToken=<redacted> written to my .npmrc file. However, if I click on the URL instead of hitting ENTER. This works!
By the way, in case this helps, I'm using my YubiKey to authenticate. Maybe there is some kind of delay the CLI fails to deal with that directly clicking the URL handles better?
Similer issues where we have the url opener for web auth. Tracking these here in this issue.
- #7644
- npm: 10.8.2
- Node.js: v20.13.1
- OS Name: Windows_NT 10.0.22631
- #7642
- npm: 10.8.2
- Node.js: v22.4.1
- OS Name: Darwin Kernel Version 23.5.0: Wed May 1 20:09:52 PDT 2024; root:xnu-10063.121.3~5/RELEASE_X86_64
- #7651
- https://github.com/npm/cli/issues/7768
manage to reproduce similer behaviour
- Run
npm login --no-progress - Hit
Enter - It will open the browser but also it will error out in terminal
~/workarea/rep $ npm login --no-progress
npm notice Log in on https://registry.npmjs.org/
Login at:
https://www.npmjs.com/login?next=/login/cli/3226b795-9794-4937-b58d-3d9820fa93e4
Press ENTER to open in the browser...
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error <https://github.com/npm/cli/issues>
npm error A complete log of this run can be found in: /Users/milaninfy/.npm/_logs/2024-07-23T15_34_01_010Z-debug-0.log
@bkuhlmann I see in your reproduction steps that you have one config progress=false. Could you please try without that config (i.e. something like npm login --progress=true) and see if that fixes your issue ?
Huh, sure enough, ensuring that --progress=true is used made this work! ...but if I disable progress then, yes, the login fails.
i also have same issue, and this is my first time using npm login so i do not have a npmrc file and my first time reporting a bug on github so if ive done anythign wrong ill try to improve on it
npm: '10.8.2',
node: '22.6.0',
$ npm login
npm notice Log in on https://registry.npmjs.org/
Login at:
https://www.npmjs.com/login?next=/login/cli/Fancy_String_Of_Numbers
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error <https://github.com/npm/cli/issues>
i have the same problem. please help me or fix it as quickly as possible.
$ npm login
npm notice Log in on https://registry.npmjs.org/
Login at:
https://www.npmjs.com/login?next=/login/cli/3f627313-80e8-40e2-ad66-21546579a5ae
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error <https://github.com/npm/cli/issues>
@admibrill try npm login --auth-type=legacy