An unexpected error occurred: "https://registry.yarnpkg.com/react: unable to get local issuer certificate" while create-react-app
Asked Answered
E

5

18

I have the following installed on my windows machine:

Node : v12.18.4

yarn : 1.19.1

create-react-app: 3.4.1

I navigated to the folder c:\temp and then tried to create react app using the following command:

c:\temp>create-react-app react-test --scripts-version 1.1.5

On executing the above command I see the following error:

Creating a new React app in C:\Temp\react-test.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

yarn add v1.19.1
[1/4] Resolving packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/react: unable to get local issuer certificate".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Temp\\react-test\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts cra-template --cwd C:\Temp\react-test has failed.

Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.

Can anyone help me here by providing their guidance to fix this issue

Enjoin answered 29/9, 2020 at 18:29 Comment(0)
W
54

Turn off the strict-ssl on yarn/npm config, and try again

yarn config set "strict-ssl" false -g

or

npm config set "strict-ssl" false -g
Woolfolk answered 12/11, 2020 at 14:4 Comment(5)
Yep. That did the trick. Thank you.Longfaced
Worked for me thank you.Clingy
This is CERTAINLY not a good move in the manner of security. Registries should have valid certificates. If they are self-signed, the user should manually verify them, or a good registry with valid certificates should be the way.Suffer
@Suffer What could be the consequences of registries not having valid certificates? Just want to understand the practical dangers of disabling strict-ssl.Analog
Why should users permanently disable security if only one package is affected? Please update your answer and describe what the commands do and provide the commands necessary for re-enabling security.Snowman
M
14

Not a big fan disabling strict-ssl.

This worked for me

yarn config set registry https://registry.npmjs.org
Marilumarilyn answered 9/1, 2022 at 11:29 Comment(2)
Will this work for yarn? I don't see how this answers the Op's question.Lieutenant
This should be the accepted answer, not blindly disabling strict-ssl.Aleida
S
0

Execute the following commands one by one to resolve the issue.

npm config set registry https://registry.npmjs.org/
npm config set "strict-ssl" false -g
npm config delete registry
Substitute answered 14/12, 2022 at 8:56 Comment(0)
S
0

After try the different options here (safest and unsafest) the problem persist. I solve that cleaning caches, specially Yarn; reboot & try again, and then voila, all works as is expected.

Surfactant answered 10/5, 2023 at 17:9 Comment(0)
I
0

Warning: Any solution that disables global security is a bad idea. You better be able to bet your career and home on this moment of "f'it".

So JUST DONT.

The previous respondents are correct,

npm config set registry https://registry.npmjs.org/

yarn config set registry https://registry.npmjs.org/

Additionally, having exported the NODE_OPTIONS environment variable...

export NODE_OPTIONS=--max-old_space_size=<memory limit>

It also aided in correcting the issue. This was for my Raspberry Pi 3 with Debian GNU/Linux 11

Inroad answered 15/5, 2024 at 4:40 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.