Environment
Windows with NVM (Node Version Manager)
Node version : v18.14.2
Description
Trying to install the stable version of yarn return an error
Command to reproduce the issue
corepack prepare yarn@stable
Output error
Internal Error: ENOENT: no such file or directory, stat '{COREPACK_HOME}\yarn\3.4.1'
Error: ENOENT: no such file or directory, stat '{COREPACK_HOME}\yarn\3.4.1'
More information about error
By looking for the root cause of the error, I was able to find at which statement the error occurs
The error occurs when installing Yarn intending to rename the temporary folder
- Into the file corepackUtils.ts
installVersion function
- On
rename statement await fs.promises.rename(tmpFolder, installFolder);
[Error: EPERM: operation not permitted, rename '{COREPACK_HOME}\corepack-35332-42750715.c38c6' -> '{COREPACK_HOME}\yarn\3.4.1'] {
errno: -4048,
code: 'EPERM',
syscall: 'rename',
path: '{COREPACK_HOME}\\corepack-35332-42750715.c38c6',
dest: '{COREPACK_HOME}\\yarn\\3.4.1'
}
Workaound
I tried to force the closing/destruction of streams but it not working.
On the other hand, by adding a delay just before the renaming, it worked
Here the delay statement : await new Promise(resolve => setTimeout(resolve, 100));
Note: you can also rename manually the tmp directory and move to the install folder
(ex '{COREPACK_HOME}\corepack-35332-42750715.c38c6' -> '{COREPACK_HOME}\yarn\3.4.1')
Environment
Windows with NVM (Node Version Manager)
Node version : v18.14.2
Description
Trying to install the stable version of yarn return an error
Command to reproduce the issue
Output error
More information about error
By looking for the root cause of the error, I was able to find at which statement the error occurs
The error occurs when installing Yarn intending to rename the temporary folder
installVersionfunctionrenamestatementawait fs.promises.rename(tmpFolder, installFolder);Workaound
I tried to force the closing/destruction of streams but it not working.
On the other hand, by adding a delay just before the
renaming, it workedHere the delay statement :
await new Promise(resolve => setTimeout(resolve, 100));Note: you can also rename manually the tmp directory and move to the install folder
(ex '{COREPACK_HOME}\corepack-35332-42750715.c38c6' -> '{COREPACK_HOME}\yarn\3.4.1')