Reputation: 13713
I'm new to nodejs and npm. I'm trying to install log4js and this is the command for the install:
npm install log4js
I'm running this from Windows Command Line and I after a while of a marker spinning I get the following error:
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "log4js"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
npm ERR! self signed certificate in certificate chain
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! C:\srv\npm-debug.log
I tried doing npm config set ca=""
like suggested here: http://blog.npmjs.org/post/78085451721/npms-self-signed-certificate-is-no-more but I'm still getting this error.
How can I solve this and install NPMs ?
Upvotes: 142
Views: 331935
Reputation: 1
I was blocked by my company Certificate to resolve the problem I followed the steps as Gregsonian said but the problem was not resolved for me for different reasons:
By doing correctly the two previous steps i can now use npm correctly
Hope it can help some people
Upvotes: 0
Reputation: 71
Our corporate environment inflicted this on us via some company cert chicanery, and this bit the Windows devs in both npm and git operations. For npm, the instructions provided previously by gregsonian (building a cert and pointing npm config to use it) still work well. (Win-10 for reference.) I prefer otherwise keeping SSL enabled.
Upvotes: 2
Reputation: 141
In my case I initially setup squid to proxy all http & https requests on my local ubuntu box, but was not aware that TLS version >= 1.3 requires ssl-bump, peek and splice TLS handshake features.
The following might help others understand what is going on "under the hood" so you can be confident that your fix is correct. If you don't use squid then skip that part, but take note of the final npm step.
Here are the steps to upgrade squid :
To enable npm ssl install, add the proxy ca-certificate.pem to the npm config
After running step 5, npm install from https://registry.npmjs.org worked fine
Upvotes: 0
Reputation: 1
If you want to trust another certificate I think its better define the environment variable to trust the new certificate NODE_EXTRA_CA_CERTS=<path to .pem file> https://nodejs.org/api/cli.html#cli_node_extra_ca_certs_file
Upvotes: 0
Reputation: 15945
Disabling strict-ssl mode will remove this error.
npm set strict-ssl false
Since this is turning off SSL security, we should try this as last step if below two steps don't help.
This issue can arise due to incompatibility between SSL certificate file of npm and node registry.
Try
1) telling your current version of npm to use node's ca instead of built in canpm config set ca=""
2) OR upgrading your version of npm
npm install npm -g --ca=null
Upvotes: 298
Reputation: 41
solve this problem with this command
npm config set strict-ssl=false
Upvotes: 4
Reputation: 321
As metioned by Akshay Vijay Jain above,
npm config set strict-ssl false
TURNING OFF SSL BEFORE INSTALLING THE LATEST VERSION:
Then install the latest version
npm install -g npm@latest
INSTALL SUCCESS!!:
See the screenshots added for clarity.
Upvotes: 24
Reputation: 432
Was getting same error when executed via Docker build. Powershell execution, however, was error free. Then modified the dockerfile with following (as suggested above):
RUN npm config set ca=""
RUN npm set strict-ssl false
This fixed the cert chain issue.
Upvotes: 6
Reputation: 1272
You can disabled certificate validation for TLS connections:
NODE_TLS_REJECT_UNAUTHORIZED=0 npm install puppeteer
Upvotes: 2
Reputation: 1708
I tried many solutions here and none really worked for me. I tried updating npm but got either a timeout (when registry was set to http://registry.npmjs.org/), or a 403 Forbidden responce (when registry was set to https://registry.npmjs.org/)
In the end, realsing that my problem was caused by being behind a proxy, what did work for me in the end was:
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
(credit: https://stackoverflow.com/a/12832637/4191296)
Upvotes: 0
Reputation: 6963
None of the answers above helped out my situation. The culprit turned out to be the package agent-base pre 6.0.1. Indeed the owner admitted to shipping out self-signed certs in a test folder of his package. This forced a reinstall -D and -g but problem is still happening.
I found this cert by searching node_modules folder for *.pem.
Still working on getting npm caches to listen to me. Of course I'm the dummy right?
I'll post back additional findings.
Solution Found
7/7/2020
Our Angular application was upgraded from 8.3 to 10.0 today. Guess what? The errors disappeared. The root cause was someone published an unsigned cert that made it's way too deep in the NPM modules library. Even NPM 6.15 had it!
Upvotes: 0
Reputation: 4692
As of February 27, 2014, npm no longer supports its self-signed certificates. The following options, as recommended by npm, is to do one of the following:
Upgrade your version of npm
npm install npm -g --ca=""
-- OR --
Tell your current version of npm to use known registrars
npm config set ca ""
Update: npm has posted More help with SELF_SIGNED_CERT_IN_CHAIN and npm with more solutions particular to different environments
Read more here
Upvotes: 3
Reputation: 14295
In CentOS and other Linux distros you need to configure NPM to use your Certificate Authorities file:
npm config set cafile "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" -g
Obviously check the file exists and contains all CA Roots you may encounter (e.g. corporate proxy).
Upvotes: 4
Reputation: 1226
While setting StrictSsl to false is an option, it compromises your npm security. I recommend not disabling it. The following instructions elaborate on Shreedhar's post to use the cafile. Though it's written from a Windows 10 machine perspective it can be adapted.
Our company uses SSL Inpsection via a proxy, so at the very least we need to include the SSL Inspection certificate. The following instructions assume you are able to use a modern web browser on the machine you are trying to use an externally reaching npm function.
npm config list
npm config set cafile "C:\Local\Path\To\cafile4npm.cer"
modifying the path and file noted in step 8.npm install
command.Upvotes: 23
Reputation:
Did you also tried settings cafile
accommodating all pems in one file? npm add root CA
If you use proxy in your .npmrc
file, I will suggest to set no_proxy
environment variable with value of your <server IP address>
Upvotes: 2
Reputation: 1037
I had the same problem on windows 10.
open windows powerShell and enter the following command:
npm config set registry http://registry.npmjs.org/
Then you can use:
npm install [your package]
Upvotes: 86
Reputation: 11
In my case, I had installed Fiddler, which has a self signed certificate which made the npm install go crazy.
See here how to remove the self signed Fiddler certificate How do you remove the root CA certificate that Fiddler installs
Upvotes: 1
Reputation: 389
I'm new to npm as well. Besides the commands mentioned in your link I tried the following and it resolved my issues:
Reference: Npm SELF_SIGNED_CERT_IN_CHAIN on Azure
Upvotes: 19