I know this question has been posted a few years ago. Since it still pops up at the top results on Google, I would like to share my proper and secure solution for this problem.
Solution for one Authority Root certificate
I would like to advise everyone to make sure to keep your connection secured by using the https registry. Also stop disabeling strict-ssl. Many are missing the point here and go for a quick fix instead of the only right solution.
You'll have to add your .pem
certificate to the .npmrc
file (npm config). When you just need to add one certificate use the following:
npm config set cafile /path/to/cert.pem
Solution for multiple Authority Root certificates
When you're company uses multiple certificates (like mine) you'll first need to combine the certificates to one .pem
by entering the following command in your terminal:
cat cert1.pem cert2.pem > cert_combined.pem
Then make sure to point the right .pem
file in your .npmrc
npm config set cafile /path/to/cert_combined.pem
Forget the solutions other people mention like ca[]="..."
and NODE_EXTRA_CA_CERTS
. This solution is tested and verified within a company that uses multiple Authority Root certificates using node v16.13.0 and npm v8.3.0.