forev3r
forev3r

Reputation: 553

How do I solve the NPM "418 I'm a teapot" error when trying to use npm install?

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:

Upvotes: 18

Views: 25424

Answers (7)

Shiv
Shiv

Reputation: 505

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.

Upvotes: 0

Ajay Venkata Raju
Ajay Venkata Raju

Reputation: 1158

After visiting many sites and testing everything i found, This Solution finally worked for me. If you are using Windows,

  1. Click windows button and type "run"
  2. Type .npmrc and open this file using your favorite editor.
  3. Replace registry=http://registry.npmjs.org/ with registry=https://registry.npmjs.org/ and save.

Note: If you have any proxy issues too..you can set your proxy like below in the same file. In my case i have a special symbol "@" in my password. When i tried changing proxy using npm config set proxy command these special characters got converted to something else :) So you could eliminate all these headaches if you set your proxy along in this file directly.

Your final .npmrc should look like below. you could remove proxy lines if you do not have any issues with proxy and do not forget to replace the port in below example with your proxy port.

registry=https://registry.npmjs.org/  
proxy=http://username:[email protected]:8080/  
https-proxy=http://username:[email protected]:8080/  
strict-ssl=false

Upvotes: 4

Nagendra Reddy
Nagendra Reddy

Reputation: 551

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

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

Upvotes: 1

rajdeepbs29
rajdeepbs29

Reputation: 1329

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).

Upvotes: 0

iwan.webdeveloper
iwan.webdeveloper

Reputation: 81

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

Upvotes: 5

Sonali more
Sonali more

Reputation: 276

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/

Upvotes: 21

forev3r
forev3r

Reputation: 553

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!

Upvotes: 37

Related Questions