How to Fix npm Self Signed Certificate Error (Without Losing Your Mind)

How to Fix npm Self Signed Certificate Error (Without Losing Your Mind)

Photo by Artiom Vallat on Unsplash

So I was trying to set up a new dev environment on a work laptop at like 11pm, running npm install on a fresh project, and immediately got smacked with this:

npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
npm ERR! errno SELF_SIGNED_CERT_IN_CHAIN
npm ERR! request to https://registry.npmjs.org/react failed, 
reason: self signed certificate in certificate chain

Cool. Love it. Nothing like a cryptic SSL error to ruin your evening.

If you've landed here, you're probably seeing some variation of that — maybe it's UNABLE_TO_VERIFY_LEAF_SIGNATURE or just a generic certificate has expired message. They're all cousins of the same problem, and honestly, the npm self signed certificate error is one of those things that catches people off guard because it has nothing to do with your code.

Why Does This Even Happen?

Here's the thing — this almost always comes down to one of two situations. Either you're on a corporate network that uses a proxy with its own SSL certificate (super common in enterprise environments), or your Node.js/npm installation is working with an outdated or misconfigured CA (Certificate Authority) store.

Corporate proxies are the usual culprit. Your company's network does SSL inspection — it intercepts HTTPS traffic, decrypts it, inspects it, then re-encrypts it with their own internal certificate. Which is... fine, I guess, from a security standpoint. But npm doesn't know about that internal cert, so it freaks out and refuses the connection.

The other scenario is less common but worth mentioning — if you're running an older version of Node, the bundled CA store might just be stale. Certificate authority stuff changes more often than you'd think.

Fix #1: Point npm to Your Corporate Certificate (The Right Way)

This is the proper fix if you're on a work machine. Your IT department should be able to give you the corporate root certificate — it's usually a .pem or .crt file. Once you've got it, you tell npm to trust it:

npm config set cafile /path/to/your-corporate-cert.pem

You can verify it got set with:

npm config get cafile

This is the cleanest solution because you're not disabling any security — you're just giving npm the context it needs to verify the certificate chain properly. In my experience, this fixes it permanently and you never have to touch it again on that machine.

If you don't know where to get the certificate file, honestly just ask IT. They deal with this all the time. You can also export it manually from your browser — in Chrome, go to the padlock on any HTTPS site, view the certificate, and export the root CA cert. A bit tedious but it works.

Fix #2: Set the NODE_EXTRA_CA_CERTS Environment Variable

This one's great if you need the fix to apply across different tools, not just npm. Instead of configuring npm specifically, you set an environment variable that Node itself uses:

On Mac/Linux, add this to your .bashrc or .zshrc:

export NODE_EXTRA_CA_CERTS=/path/to/your-corporate-cert.pem

On Windows (PowerShell):

[System.Environment]::SetEnvironmentVariable("NODE_EXTRA_CA_CERTS", "C:\path\to\your-corporate-cert.pem", "User")

Then restart your terminal. This is handy because it also covers tools like Yarn, pnpm, or anything else that runs on Node and might hit the same SSL verification issue. I've seen teams set this globally on dev machines as part of their onboarding scripts — smart move if your company has a lot of devs hitting this.

Fix #3: Disable Strict SSL (Use With Caution)

Alright, I'm going to include this one because people do it and sometimes it's the only option when you're in a pinch — but I want to be upfront that it's not ideal for anything beyond local development or a quick temporary fix.

npm config set strict-ssl false

This tells npm to stop verifying SSL certificates entirely. It'll work, your packages will install, and you'll move on with your life. But you're essentially turning off the part of npm that checks whether you're actually talking to the real npmjs.org. On a corporate network where SSL inspection is happening, the risk is relatively low. In other contexts, it's a genuine security concern.

If you go this route, at least limit it to your local config and undo it when you're done:

# Check your current config
npm config list

# To revert later
npm config set strict-ssl true

Seriously though — use Fix #1 or Fix #2 if at all possible.

Fallback: Update Node.js

If none of the above applies — you're not behind a corporate proxy, your certificate stuff looks fine — try updating Node.js. Old versions sometimes have CA store issues that just... go away with an update. Grab the latest LTS from nodejs.org or use a version manager:

# If you're using nvm
nvm install --lts
nvm use --lts

And while you're at it, update npm itself:

npm install -g npm@latest

I've had this silently fix SSL-related weirdness more than once. Worth trying before you go too deep into certificate debugging rabbit holes.

One more thing — if you're running this in a Docker container or CI pipeline, the certificate issue might be at the image level. You'd need to add the CA cert to the container's trust store during the build step. That's a whole other post, but worth knowing if none of this is sticking.

Hope this saves you the hour of Googling I had to do at 11pm. Fix #1 with the cafile setting is almost always the answer on corporate machines — get that cert file from IT and you'll be good.

Related: How to Fix npm Error Code self_signed_cert_in_chain (Quick Fix)

๋Œ“๊ธ€

Mojang Session Servers Down? Here's Why You Can't Log Into Minecraft Right Now

Photo by Patrik Kernstock on Unsplash So you sit down to play some Minecraft, probably after a long day, maybe you've got friends waiting in a server lobby, and you get smacked with this: Failed to connect to the server. Error: Authentication servers are down for maintenance. Or sometimes it shows up as: Failed to login: Invalid session (Try restarting your game and the launcher) Yeah. The Mojang session servers are down, or at least they're not talking to your game properly. I've seen this come up constantly in forums and Discord servers whenever there's a Mojang outage, and the frustrating part is — half the time people don't even realize it's not their fault. Here's what's actually going on. Why This Happens Minecraft doesn't just let you waltz into a multiplayer server. Every time you connect, your client reaches out to Mojang's session servers at session.minecraft.net to verify you...

what is art therapy AI painting checker Introducing the AI HTP Test Site: A New Era in Art Therapy

 #what is art therapy #art therapy activities   AI Art Above is the AI ​​picture psychological test. Below is the AI ​​HTP tree human house test.  Psychotherapy test AI Art Psychotherapy HTP test Introducing the AI HTP Test Site: A New Era in Art Therapy What Is HTP? HTP (House-Tree-Person) is a well-known projective drawing test commonly used in art therapy and psychological evaluation. Participants draw a house, a tree, and a person, and mental health professionals interpret these drawings to gain insights into the individual’s emotional state, personality traits, and underlying issues. AI Meets HTP Thanks to advancements in artificial intelligence, the HTP test has evolved. Our AI HTP Test Site allows you to upload your drawings and receive a detailed, automated analysis. The system evaluates various elements—line thickness, spatial arrangement, color usage, and more—to provide immediate, data-drive...

์ด ๋ธ”๋กœ๊ทธ ๊ฒ€์ƒ‰

Zoho Mail IMAP Not Working: Every Fix I've Actually Used

Quick Summary Zoho Mail IMAP stops working for the dumbest reasons - wrong port, 2FA blocking app passwords, or DNS that looks fine but isn't. I've fixed this across Outlook 2016, iPhones, Android, and Mac Mail, and the root cause is almost always one of four things. Here's the exact step-by-step with real menu paths so you're not clicking around for two hours like I was the first time. Photo by Juanjo Jaramillo on Unsplash It was a Monday morning. One of our sales guys walks up and says his Outlook stopped pulling emails from Zoho. Just stopped. Overnight. Nothing changed - or so he said. Checked his machine, checked the account settings, everything looked right on the surface. Port 993, SSL enabled, correct email address. And yet. Nothing. Here's the thing - Zoho Mail IMAP issues have this annoying pattern where the settings look correct but something underneath is broken. Could be an app password that got invalidated when someone toggled 2FA. Could be IMAP ac...
↑