Yarn is attempting to use the wrong version

72 views Asked by At

I have Node.js v20 with corepack enabled on my PC. When I run yarn -v it shows v4.1.0 (latest). But when I run yarn dlx create-react-app my-app --template typescript in an empty directory it comes back with this error:

Internal Error: ENOENT: no such file or directory, stat 'C:\Users\me\AppData\Local\node\corepack\yarn\4.0.1'
Error: ENOENT: no such file or directory, stat 'C:\Users\me\AppData\Local\node\corepack\yarn\4.0.1'

This error also appears if I just run yarn dlx blah.

Looking under %LOCALAPPDATA%\node\corepack\yarn there is no 4.0.1 directory (but there are several others, including 4.1.0).

Why is it trying to access v4.0.1 and how do I fix this?

1

There are 1 answers

0
Mike Lowery On

Finally ran across a corepack bug report that pretty much captures this issue. Unfortunately nobody is currently working it.

Another finding was that running yarn dlx create-react-app .\my-app --template typescript requires Yarn v4.0.1 whereas running yarn create react-app .\my-app --template typescript used v4.1.0 all the way through. The latter is also the recommended way to initialize a new React app.