npm install fails (installing MERN stack)

  • A+
Category:Languages

I'm trying to install the MERN stack on my Mac, however, when I run the following command:

sudo npm install -g mern-cli 

I get this error message:

request to https://registry.npmjs.org/mern-cli failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: registry.npmjs.org. is not in the cert's altnames: DNS:a.sni.fastly.net, DNS:a.sni.global-ssl.fastly.net" 

I tried several things, like running the following command (which solved the problem for others):

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

However, this doesn't solve the problem. Also reinstalling Node completely didn't solve the problem. How to solve this?

EDIT: Full debug log

0 info it worked if it ends with ok 1 verbose cli [ '/usr/local/bin/node', 1 verbose cli   '/usr/local/bin/npm', 1 verbose cli   'install', 1 verbose cli   '-g', 1 verbose cli   'mern-cli' ] 2 info using npm@5.6.0 3 info using node@v8.11.4 4 verbose npm-session f5dd10c6d19e4605 5 silly install loadCurrentTree 6 silly install readGlobalPackageData 7 silly fetchPackageMetaData error for mern-cli@latest request to https://registry.npmjs.org/mern-cli failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: registry.npmjs.org. is not in the cert's altnames: DNS:a.sni.fastly.net, DNS:a.sni.global-ssl.fastly.net" 8 verbose type system 9 verbose stack FetchError: request to https://registry.npmjs.org/mern-cli failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: registry.npmjs.org. is not in the cert's altnames: DNS:a.sni.fastly.net, DNS:a.sni.global-ssl.fastly.net" 9 verbose stack     at ClientRequest.req.on.err (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/index.js:68:14) 9 verbose stack     at emitOne (events.js:116:13) 9 verbose stack     at ClientRequest.emit (events.js:211:7) 9 verbose stack     at TLSSocket.socketErrorListener (_http_client.js:387:9) 9 verbose stack     at emitOne (events.js:116:13) 9 verbose stack     at TLSSocket.emit (events.js:211:7) 9 verbose stack     at emitErrorNT (internal/streams/destroy.js:64:8) 9 verbose stack     at _combinedTickCallback (internal/process/next_tick.js:138:11) 9 verbose stack     at process._tickCallback (internal/process/next_tick.js:180:9) 10 verbose cwd /Users/Bjorn/Desktop/StoryOfAms 11 verbose Darwin 17.7.0 12 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "mern-cli" 13 verbose node v8.11.4 14 verbose npm  v5.6.0 15 error request to https://registry.npmjs.org/mern-cli failed, reason: Hostname/IP doesn't match certificate's altnames: "Host: registry.npmjs.org. is not in the cert's altnames: DNS:a.sni.fastly.net, DNS:a.sni.global-ssl.fastly.net" 16 verbose exit [ 1, true ] 

 


As many other answers are pointing out, this seems to be a global issue, I'm also experiencing the same. I did fix the problem by (like suggested by @muradm and others) following the instructions available at https://status.npmjs.org/incidents/v22ffls5cd6h.

The instructions there are that you check yourself what is the IP answering to www.npmjs.com by using the dig command, or using google DNS tool.

The result of that, was to include in my Hosts file the following line:

104.16.109.30   registry.npmjs.org 

This solved the issue for me. Remember this is a temporary fix and should be removed after the weekend! Good luck!

-- edit --

Also, this is assuming that you are using registry.npmjs.org as your NPM registry endpoint (which is the default setting). To check that, you can run:

npm config get registry 

If that returns "https://registry.npmjs.com/" for example, you can try adding to your hosts:

104.16.109.30   registry.npmjs.com 

Which I just tested and works fine!

P.S.: If for any reason you are unsure how to edit hosts file, you can check here: https://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: