Skip to main content Link Menu Expand (external link) Document Search Copy Copied


Published on 2023-03-28

Table of contents

  1. What is it?
  2. Issue sample
  3. All Platforms
    1. Yarn 1.x
    2. Yarn 2.x

What is it?

Yarn is an alternative to npm as package manager for the Node.js runtime.

Official Documentation

You can always check the general troubleshooting guide before continuing.

Issue sample

The error might look like this when using Yarn:

Yarn 1.x

  Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure
  .. <stack-trace> ..

Yarn 2.x

YN0001: │ GotError: unable to get local issuer certificate

All Platforms

Yarn 1.x

Yarn 1.x takes many configurations directly from Npm by reading the .npmrc and supports the Node.js environment variables. For that reason you can follow the guid for npm here.

Yarn 2.x

Yarn 2.x doesn’t use the configuration from your .npmrc files anymore; it instead reads all of the configuration from the .yarnrc.yml files whose available settings can be found here. The .yarnrc.yml file must be placed inside your Node.js project and not inside your user directory in order to work correctly.

This means that configurations for certificates must be done inside .yarnrc.yml. You can configure Yarn to use a central trusted CA certificate bundle file in pem - Base64 format using the following entry in the config file:

# .yarnrc.yml

caFilePath: "<path to pem file>"

The path to the pem file can be absolute or relative.

Another configuration would be httpsCertFilePath which works like caFilePath but for the whole SSL certificate chain and not only the trusted root CA certificate. So if you have problems with intermediate certificates, this would be the place to check.

Do not use settings like yarn config set enableStrictSsl false or npm config set strict-ssl false because they disable the security feature completely even if you are using a self-signed certificate. It is always better to secure the SSL connection by making a certificate known to npm/Node.js.