Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Print full URL in error message when it fails to load a module #144

Open
Que3216 opened this issue Sep 27, 2016 · 10 comments
Open

Print full URL in error message when it fails to load a module #144

Que3216 opened this issue Sep 27, 2016 · 10 comments

Comments

@Que3216
Copy link

Que3216 commented Sep 27, 2016

This is related to: npm/npm#11834

If you use artifactory for your npm registry then npm prints a rather confusing error message when it fails to load a module:

> npm install i-do-not-exist --registry https://somedomain/artifactory/api/npm/all-npm
npm ERR! 404 Not Found: artifactory
npm ERR! 404
npm ERR! 404  'artifactory' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

The 'artifactory' name is incorrectly extracted at https://github.com/npm/npm-registry-client/blob/master/lib/request.js#L276.

This has been consistently confusing devs on our team, and makes to tricky to hunt down the offending node module.

Would you accept a PR that adds a line to the error message with the full URL? For example the above error message would now become:

> npm install i-do-not-exist --registry https://somedomain/artifactory/api/npm/all-npm
npm ERR! 404 Not Found: artifactory
npm ERR! 404 GET request for 'https://somedomain/artifactory/api/npm/all-npm/i-do-not-exist' returned a 404
npm ERR! 404
npm ERR! 404  'artifactory' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
@Que3216
Copy link
Author

Que3216 commented Oct 3, 2016

Pinging this ticket (@isaacs, @othiym23). Would you accept a PR to print the full URL?

@ghost
Copy link

ghost commented Oct 7, 2016

Issue the PR! This error is killing me!

@matthewwiesen
Copy link

Running across this same issue.

@Que3216
Copy link
Author

Que3216 commented Nov 22, 2016

Anyone with admin access to this repro willing to approve a PR?

@Que3216
Copy link
Author

Que3216 commented Nov 22, 2016

(@iarna?)

@jgeorgeson
Copy link

So the error message is basically assuming that a certain part of the URL is the package name? Why not report the error with the package name that was used to construct the URL returning the 404, and leave the full URL as debug output? I don't really care what the full URL was on my first pass , I know what my configured registry URL is and I just want to know what dependency it couldn't find.

@warandpeace
Copy link

+1 This is causing issues for me as well, renders our npm artifactory mirror unusable.

@zkat
Copy link
Contributor

zkat commented May 1, 2017

Sorry I haven't responded to this one: this is fixed in npm@5 already (and even includes the version range that was requested, so you would see, like Not Found: i-do-not-exist@^5.

Parsing out the URL like this is super janky and just generally bound to be a pain. I'd rather do it "right" and pass in specifier information (which is what pacote does, and this what npm@5 does).

That's all in npm/npm#15666

@warandpeace
Copy link

Awesome, thank you so much @zkat!!

@zkat
Copy link
Contributor

zkat commented May 2, 2017

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

5 participants