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

Installing non-existent npm packages causes general "Failed to fetch" error due to missing CORS in the npm registry #1

Open
naruaway opened this issue Sep 28, 2023 · 0 comments

Comments

@naruaway
Copy link
Owner

naruaway commented Sep 28, 2023

Trying to install non-existent npm package such as this-pkg-does-not-exist-6820863782039188 causes Failed to fetch error, which cannot be distinguished from real network error.

This is because registry.npmjs.org does not return Access-Control-Allow-Origin: * for "HTTP 404 Not Found" responses.

See https://github.com/naruaway-sandbox/demo-npm-in-browser-not-found-cors for more details and reproduction steps.

I reported in npm/feedback#117 (comment) as well.

Actual

npm ERR! Failed to fetch

npm ERR! A complete log of this run can be found in: /home/web/.npm/_logs/2023-09-28T05_07_54_094Z-debug-0.log

Expected (the same as npm CLI in local machine)

npm ERR! code E404
npm ERR! 404 Not Found - GET http://localhost:8745/this-pkg-does-not-exist-6820863782039188 - Not found
npm ERR! 404
npm ERR! 404  'this-pkg-does-not-exist-6820863782039188@*' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /home/web/.npm/_logs/2023-09-28T05_07_19_717Z-debug-0.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant