corepack
corepack copied to clipboard
corepack won't install yarn
$ corepack prepare yarn@stable --activate
Preparing yarn@stable for immediate activation...
Internal Error: ENOENT: no such file or directory, stat 'C:\Users\jop\.node\corepack\yarn\3.2.3'
Error: ENOENT: no such file or directory, stat 'C:\Users\jop\.node\corepack\yarn\3.2.3'
After seeing this error, I tried to assist it by making the directory but yarn.js is not found
$ New-Item -ItemType Directory -Force C:\Users\jop\.node\corepack\yarn\3.2.3
$ corepack prepare yarn@stable --activate
Preparing yarn@stable for immediate activation...
$ yarn
Internal Error: Cannot find module 'C:\Users\jop\.node\corepack\yarn\3.2.3\yarn.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
at Module.loadMainModule (C:\Program Files\nodejs\node_modules\corepack\dist\corepack.js:16234:70)
at Module.runVersion (C:\Program Files\nodejs\node_modules\corepack\dist\corepack.js:15878:52)
at executePackageManagerRequest (C:\Program Files\nodejs\node_modules\corepack\dist\corepack.js:16123:62)
at async BinaryCommand.validateAndExecute (C:\Program Files\nodejs\node_modules\corepack\dist\corepack.js:12484:26)
at async Cli.run (C:\Program Files\nodejs\node_modules\corepack\dist\corepack.js:12145:24)
at async main (C:\Program Files\nodejs\node_modules\corepack\dist\corepack.js:16163:16)
$ corepack prepare pnpm@latest --activate
Preparing pnpm@latest for immediate activation...
$ pnpm
Version 7.11.0
That's strange, I don't repro it 🤔
What version of Corepack are you using?
I used winget install OpenJS.NodeJS.LTS and ran corepack enable
Version is
$ corepack --version
0.12.1
On more recent versions, we've switched the default COREPACK_HOME from the user home directory to the AppData one, which might help if you're seeing this because of a permission issue. Maybe you could try to upgrade Corepack to see if that solves it?
To upgrade from windows install with machine wide nodejs... I wonder if I can setup winget to install nodejs inside appdata.
I use gsudo to run as elevated user
$ $ENV:NPM_CONFIG_PREFIX="C:\Program Files\nodejs"
$ sudo npm install -g corepack
$ corepack prepare yarn@stable --activate
Preparing yarn@stable for immediate activation...
Internal Error: ENOENT: no such file or directory, stat 'C:\Users\jop\AppData\Local\node\corepack\yarn\3.2.3'
Error: ENOENT: no such file or directory, stat 'C:\Users\jop\AppData\Local\node\corepack\yarn\3.2.3'
$ corepack --version
0.14.0
I had this issue as well, trying to install yarn 3.1.1 on windows.
Corepack version 0.14.0
My workaround was to create the 3.1.1 folder in AppData\Local\node\corepack\yarn, and then download the yarn.js file manually there from https://repo.yarnpkg.com/3.1.1/packages/yarnpkg-cli/bin/yarn.js
I am currently having this issue on corepack v0.14.2.
PS C:\Windows\system32> corepack enable
PS C:\Windows\system32> corepack prepare yarn@stable --activate
Preparing yarn@stable for immediate activation...
Internal Error: ENOENT: no such file or directory, stat 'C:\Users\{redacted}\AppData\Local\node\corepack\yarn\3.2.4'
Error: ENOENT: no such file or directory, stat 'C:\Users\{redacted}\AppData\Local\node\corepack\yarn\3.2.4'
PS C:\Windows\system32> corepack --version
0.14.2
Also, I am trying to set up a build server and I'm concerned that using the user's appdata folder will be problematic if the build process doesn't use the logged in user.
Perhaps it would be a good idea to consider using a location like the one returned by System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData) in .NET?
Same issue with corepack --version: 0.14.2 and a fresh install of node v18.12.1
Same here. Windows 11, Corepack 0.14.1, fresh Node 16.18.1 install, trying to install Yarn 3.
> corepack prepare yarn@stable --activate
Preparing yarn@stable for immediate activation...
Internal Error: ENOENT: no such file or directory, stat 'C:\Users\tom\AppData\Local\node\corepack\yarn\3.3.0'
Error: ENOENT: no such file or directory, stat 'C:\Users\tom\AppData\Local\node\corepack\yarn\3.3.0'
There is a "1.22.19" directory from having run corepack enable -all in an attempt to fix this. It's like the attempt to install yarn 3 doesn't actually download it before trying to activate it? After trying @aaryg's workaround above, it seems to have worked. So it's not the activation process that fails, it's the download?
Hi all,
I encountered a similar issue with NPM and tried to identify a way to reproduce it.
Environment:
- Windows 10 64 bits
- No
nodeexecutable accessible with thePATHenvironment variable.
Project: directory containing only a package.json file.
{
"packageManager": "[email protected]"
}
Basically, here's what I do:
- Remove any
%USERPROFILE%\.nodedirectory. - Install Node.js in a new directory.
- Open a command prompt
cmdin the project directory. - Add the Node.js install directory to the
PATHenvironment variable. - Show Node version:
node -v - Enable
NPMsupport through Corepack:corepack enable npm - Show NPM version:
npm -v - Show again NPM version:
npm -v
Results:
- Node 16.16.0 (Corepack 0.10.0) : both commands 7 and 8 return
6.14.17 - Node 16.17.0 (Corepack 0.12.1) : command 7 fails with the following message:
Internal Error: ENOENT: no such file or directory, stat 'C:\Users\<username>\.node\corepack\npm\6.14.17' Error: ENOENT: no such file or directory, stat 'C:\Users\<username>\.node\corepack\npm\6.14.17'
However, command 8 successfully returns 6.14.17.
Please find enclosed output with each Node.js/Corepack distribution. It seems the issue is also present with Node 18 distributions.
Thanks in advance for your help! BR
node-16.16.0-output.log node-16.17.0-output.log
EDIT:
Not sure it is relevant, but I forgot to mention that my %USERPROFILE% environment variable contains a space: C:\Users\Firstname Lastname
If I manually go to \AppData\Local\node\corepack and go the the downloaded folder. Create the yarn/3.4.1/ folder myself and put the downloaded folder there, then the next run of the command will work and Yarn now works on my machine again.
A workable workaround from #246 for Windows users:
- Open
C:\Program Files\nodejs\node_modules\corepack\dist\lib\corepack.cjsfile. - Search this line:
await import_fs2.default.promises.rename(tmpFolder, installFolder). If not found, try to searchrename(tmpFolder, installFolder). - Add a new line
await new Promise(resolve => setTimeout(resolve, 100));before to the found line in setp 2. - Save the file.
- Run the upgrade command:
corepack prepare yarn@stable --activate. - Check the version:
yarn -v.
I had this problem. The culprit was ~/.yarnrc.yml with path to old yarn installation.
Corepack was properly installing yarn, but then it tried to use that old version.