Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] npm login - Exit handler never called! #7612

Closed
2 tasks done
DanielLey21 opened this issue Jun 26, 2024 · 11 comments · Fixed by npm/npm-profile#144
Closed
2 tasks done

[BUG] npm login - Exit handler never called! #7612

DanielLey21 opened this issue Jun 26, 2024 · 11 comments · Fixed by npm/npm-profile#144
Assignees
Labels
Bug thing that needs fixing Priority 1 high priority issue

Comments

@DanielLey21
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • 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
@DanielLey21 DanielLey21 added Bug thing that needs fixing Needs Triage needs review for next steps labels Jun 26, 2024
@kchindam-infy
Copy link

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.

@bkuhlmann
Copy link

bkuhlmann commented Jul 9, 2024

Hi. 👋 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.

@kchindam-infy
Copy link

@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

@bkuhlmann
Copy link

bkuhlmann commented Jul 13, 2024

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?

@milaninfy
Copy link
Contributor

milaninfy commented Jul 19, 2024

Similer issues where we have the url opener for web auth. Tracking these here in this issue.

@milaninfy milaninfy added Priority 1 high priority issue and removed Needs Triage needs review for next steps labels Jul 19, 2024
@milaninfy
Copy link
Contributor

manage to reproduce similer behaviour

  1. Run npm login --no-progress
  2. Hit Enter
  3. 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

@milaninfy
Copy link
Contributor

@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 ?

@bkuhlmann
Copy link

Huh, sure enough, ensuring that --progress=true is used made this work! ...but if I disable progress then, yes, the login fails.

@Tomtom-Skywalker
Copy link

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>

@admibrill
Copy link

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>

@milaninfy
Copy link
Contributor

@admibrill try npm login --auth-type=legacy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 1 high priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants