How can I add CA certificate in Windows to NODE_EXTRA_CA_CERTS?

221 views Asked by At

I need to install the 'generator-liferay-theme' package via npm, but I when I run the command 'npm i -g [email protected]', I get the following error:

npm WARN registry Unexpected warning for http://registry.npmjs.org/: Miscellaneous Warning UNABLE_TO_GET_ISSUER_CERT_LOCALLY: request to https://registry.npmjs.org/generator-liferay-theme failed, reason: unable to get local issuer certificate
npm WARN registry Using stale package data from http://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! request to https://registry.npmjs.org/generator-liferay-theme/-/generator-liferay-theme-10.0.0.tgz failed, reason: unable to get local issuer certificate

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\<username>\AppData\Roaming\npm-cache\_logs\2023-09-15T15_04_22_373Z-debug.log

After a lot of Googling and research, I believe that the issue is with my company's proxy using it's own root CA that Node doesn't trust. One potential solution I have found is to set the 'NODE_EXTRA_CA_CERTS' environment variable to the path of the CA pem file. All of the solutions to similar questions I have found on Stack Overflow so far say to set this to the path of the CA. The issue is, I am on Windows and Windows stores CA Certs in the registry, not in the file system. I would like to know if it is possible to do something like create a pem file from the cert in the registry so I can set it's path as a value to the NODE_EXTRA_CA_CERTS environment variable, or if there are any other potential solutions that I could try.

I have tried the following command: npm config set registry http://registry.npmjs.org/ with no joy. I also tried to find the CA cert using Git Bash and set the NODE_EXTRA_CA_CERTS variable in the .bashrc file, trying different versions of the package, changing Node version and npm version (Liferay 7.3 requires Node v10.15.3 and npm v6.4.1), again with no luck as I keep getting the exact same error.

0

There are 0 answers