vite
vite copied to clipboard
vite cannot support yarn2 Global Cache
Describe the bug
when i use yarn berry and set enableGlobalCache: true
.
i got an error look's like this:
X [ERROR] Could not resolve "./C:/Users/<User Name>/AppData/Local/Yarn/Berry/cache/<Package>.zip/node_modules/<Path to>.js"
it's maybe an esbuild bug.
Reproduction
https://github.com/frg2089/vite-bug
System Info
Need to install the following packages:
envinfo
Ok to proceed? (y) y
System:
OS: Windows 10 10.0.25140
CPU: (8) x64 AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
Memory: 5.53 GB / 17.94 GB
Binaries:
Node: 18.2.0 - D:\Program Files\nodejs\node.EXE
Yarn: 4.0.0-rc.6 - D:\Program Files\nodejs\yarn.CMD
npm: 8.11.0 - D:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.25140.1000.0), Chromium (103.0.1264.44)
Internet Explorer: 11.0.25140.1000
Used Package Manager
yarn
Logs
Click to expand!
placeholder | sample |
---|---|
<Path To Local Appdata> |
%LOCALAPPDATA% |
<Path To Project> |
e.g. D:\Repos\vite-demo |
vite v2.9.13 dev server running at:
> Local: http://localhost:3000/
> Network: use `--host` to expose
ready in 523ms.
✘ [ERROR] Could not resolve "./<Path To Local Appdata>/Yarn/Berry/cache/@microsoft-fast-components-npm-2.30.6-d634ccef7f-7.zip/node_modules/@microsoft/fast-components/dist/esm/index.js"
dep:@microsoft_fast-components:2:14:
2 │ export * from "./<Path To Local Appdata>/Yarn/Berry/cache/@microsoft-fast-components-npm-2.30.6-d...
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
09:25:02 [vite] error while updating dependencies:
Error: Build failed with 1 error:
dep:@microsoft_fast-components:2:14: ERROR: Could not resolve "./<Path To Local Appdata>/Yarn/Berry/cache/@microsoft-fast-components-npm-2.30.6-d634ccef7f-7.zip/node_modules/@microsoft/fast-components/dist/esm/index.js"
at failureErrorWithLog (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1605:15)
at <Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1251:28
at runOnEndCallbacks (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1034:63)
at buildResponseToResult (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1249:7)
at <Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1358:14
at <Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:666:9
at handleIncomingPacket (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:763:9)
at Socket.readFromStdout (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:632:7)
at Socket.emit (node:events:527:28)
at addChunk (node:internal/streams/readable:324:12)
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines.
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
I suppose the problem here is your project locates in C drive but the yarn global cache locates in D drive and Vite fails to handle that. related: #4302 #4635
I suppose the problem here is your project locates in C drive but the yarn global cache locates in D drive and Vite fails to handle that.
my global cache locates in C drive and my project locates in D drive.
My bad. Anyway, the cross-drive symlink/junction is the root cause here. Maybe it will work if you move the global cache to C drive.
Maybe it will work if you move the global cache to C drive.
I disabled the global cache and it worked.
they will storaged packages into <project path>\.yarn\cache
.
I can reproduce the issue on a Windows 11
machine. We have enableGlobalCache: true
in our yarnrc.yml
file, and I'm getting this error
The error's not exclusive to this package. I'm getting similar errors for other packages like react
and @emotion/cache
.
I was able to resolve the issue by disabling the global cache, as @frg2089 suggested.
I'd be glad to provide more info if useful.
@HasanMothaffar Would you test if moving global cache to the same drive works?
yarn config set cache-folder <path>
is the command, I suppose.
https://classic.yarnpkg.com/en/docs/cli/cache#toc-change-the-cache-path-for-yarn
Closing as lack of response and I guess this is a duplicate of #4635