question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vite cannot support yarn2 Global Cache

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sapphi-redcommented, Oct 17, 2022

Closing as lack of response and I guess this is a duplicate of #4635

0reactions
sapphi-redcommented, Jul 26, 2022

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Yarn 3.1, Vite 2.9, cannot find package vite - Stack Overflow
When trying to build the app with Vite I'm seeing an error. ... import vite-virtual-ec56a6c02a/0/cache/vite-npm-2.9.13-cda1bb45b9-a5e501b920 ...
Read more >
Yarn caching doesn't work - Visual Studio Feedback
I'm trying to cache my yarn node_modules and following the examples in the documentation, I'm unable to get it work, it always gives...
Read more >
[AskJS] Is someone using Yarn v2 in business? - Reddit
Zero-Installs represents committing the .yarn/cache folder to a repository (It's ... Yarn 2 currently supports only 4 lifecycle scripts:.
Read more >
Heroku Node.js Support
This cache is used to store caches for npm, yarn, and bower. You can disable all caching for Node.js apps if you prefer:...
Read more >
Plug'n'Play | Yarn - Package Manager
Native support; Support via plugins; Incompatible ... we still ended up unable to optimize some particular patterns - causing not only the disk...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found