npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.46k stars 3.15k forks source link

npm install returns an error 403, cloudflare captcha page is returned instead of package json #1566

Closed spankandex closed 3 years ago

spankandex commented 4 years ago

What / Why

I have a ubuntu server 18.04 in north america and installed nodejs / npm from official repositories. On this specific server, which has no specific network configuration, no vpn, nothing unsual, when trying to run "npm install" commands, it return a 403 error, cause the request is getting a cloudflare page asking for a captcha. I also don't have any specific configuration on npm cli. Everything is brand as new, virgin as it is.

Steps to Reproduce

root@ns105270:~# npm install npm -g npm ERR! registry error parsing json npm ERR! Linux 4.15.0-112-generic npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "npm" "-g" npm ERR! node v8.10.0 npm ERR! npm v3.5.2

npm ERR! Unexpected token < in JSON at position 0 npm ERR! <!DOCTYPE html> npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! Attention Required! | Cloudflare npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR!

npm ERR! npm ERR!
npm ERR!
npm ERR!

One more step

npm ERR!

Please complete the security check to access registry.npmjs.org

npm ERR!
npm ERR! npm ERR!
npm ERR!
npm ERR!
npm ERR!
npm ERR! npm ERR!
npm ERR!
npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR!
npm ERR!
npm ERR! npm ERR!
npm ERR!
npm ERR! npm ERR!
npm ERR!
npm ERR! npm ERR! npm ERR! npm ERR!
npm ERR!
npm ERR!
npm ERR!
npm ERR!
npm ERR! npm ERR!
npm ERR!
npm ERR!
npm ERR!

Why do I have to complete a CAPTCHA?

npm ERR! npm ERR!

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

npm ERR!
npm ERR! npm ERR!
npm ERR!

What can I do to prevent this in the future?

npm ERR! npm ERR! npm ERR!

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

npm ERR! npm ERR!

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

npm ERR! npm ERR! npm ERR! npm ERR!
npm ERR!
npm ERR!
npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR!
npm ERR!
npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! npm ERR! If you need help, you may report this error at: npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request: npm ERR! /root/npm-debug.log

Expected Behavior

As I have configured on other servers, the package should be installed instead of appearing that html cloudflare asking for a captcha response.

I could use a VPN service to surround the problem, however... this could happen on other servers and to anyone else. I already tried to change the registry to HTTP instead of HTTPS.

Thank you

jf-marino commented 4 years ago

Also having this same issue, looks like my ISP set up some aggressive caching through Cloudflare and downloads to private packages stop working when they turn that on (they seem to turn it on on Fridays and off on Mondays 🙄 ). Is there a way to bypass that without the ISP changing their config?

As a workaround I just connect from my mobile network whenever I'm about to do an install, but it's very annoying.

Thanks!

noahcooper commented 4 years ago

I just started running into this problem after using npm for years. None of the reasons described on the Cloudflare CAPTCHA page apply to me -- they seem to suggest this has something to do with malware, but I don't think that's actually the case.

darcyclarke commented 3 years ago

npm v6 is no longer in active development; We will continue to push security releases to v6 at our team's discretion as-per our Support Policy.

If your bug is preproducible on v7, please re-file this issue using our new issue template.

If your issue was a feature request, please consider opening a new RRFC or RFC. If your issue was a question or other idea that was not CLI-specific, consider opening a discussion on our feedback repo

Closing: This is an automated message.