How do I solve the NPM “418 I'm a teapot” erro

2019-03-21 03:33发布

问题:

I've been trying to install Yeoman and Gulp on a server that has a corporate proxy using the following command:

npm install -g yo gulp

However when I run this comand (or any "npm install" command) I get hit with:

npm ERR!       E418
npm ERR! 418 I'm a teapot: gulp@latest

I'm pretty confident that this is an issue pertaining to the proxy but I can't figure out what exactly is causing it.

Some tests I've done:

  • I added the proxy to my npmrc file with login information for authentication and I believe it's entered properly. If I change any part of the username or password my error changes to an E407 (authentication failed).

  • I ran "npm config set strict-ssl false" and that seemed to not do anything.

  • I tried running different installs and I still just get "418 I'm a teapot package@latest".

回答1:

So after a few more hours of digging through forums and blogs the solution was to change my registry from "http://registry.npmjs.org/" to "https://registry.npmjs.org/".

Apparently when on some proxies the registry will redirect to the address but add port 443 to the address if trying to connect without the https.

Hope this helps anyone else experiencing this issue!



回答2:

I also got this error in my project and the main reason is change in our proxy settings. So i would like to suggest to check your proxy settings ... few commands which i used to resolve this error...

npm set strict-ssl false 
npm config set registry https://registry.npmjs.org/

check= https://registry.npmjs.org/



回答3:

Thanks for answering now my npm not showing Err 418 i'm a teapot again.

You must update npm config like this :

npm set strict-ssl false 
npm config set registry https://registry.npmjs.org/

Try again install package using npm..



回答4:

Npm team sent this statement for the issue-"At peak, the 418 responses were 0.01% of traffic. npm has a great many users (over 10M), so given traffic over the time of the incident that works out to between 500 and 1000 actual users affected. Obviously, even one user bitten by a bug is more than we'd like, but relative to our scale it was not a major issue. The specific proxy configuration necessary to trigger the bug is relatively rare, so even among users behind proxies most people were not affected. Once we were alerted to the bug in our header parsing, the ops team quickly deployed the fix."

So, surely the people behind the proxy are affected as I faced the same issue. So, solution here is-

Check proxy- npm get proxy and npm get https-proxy if both are set to none, please set it to-

npm set proxy http://proxyAddr:8000 npm set https-proxy https://proxyAddr:8000

then try again.

If the issue still persists check the registry for npm-

npm get registry if http://registry.npmjs.org/ then,

change it to npm config set registry https://registry.npmjs.org/ (This should fix the issue, for me it worked).



回答5:

When you are behind a corporate firewall at then you get this issue, to resolve this I have followed the following steps:

npm set strict-ssl false npm config set registry https://registry.npmjs.org/

If you are behind corporate proxy then you can use the following command as well: npm config set https-proxy http://IP:PORT/

Or Directly go to your .npmrc file and point to https instead of http.



回答6:

change registry from http://registry.npmjs.org/ to https://registry.npmjs.org/ using below command:

npm config set registry https://registry.npmjs.org/