Open demigor opened 1 year ago
This problem is caused by Windows not supporting relative paths between drives. Yarn avoids this with a hack where they pretend that relative paths between drives are allowed, while esbuild doesn't do this. A workaround is to make sure everything in the build is on the same drive when using esbuild.
I moved Yarn cache to D: drive and it is still the same error. Just "D:\D:\...". Looks like path concatenation routine does not respect drive-letter rooted paths, bluntly contatenating them or so.
Can you provide a way to reproduce the issue? Specific instructions to follow or a repository with sample code would work.
I'm not sure whether this is the same with the original issue, here is my steps.
➜ Repos yarn create vite
➤ YN0000: · Yarn 4.0.0-rc.49
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + create-vite@npm:4.4.1
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0013: │ A package was added to the cache (+ 250.43 KiB).
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: · Done with warnings in 0s 47ms
√ Project name: ... vite-project
√ Select a framework: » React
√ Select a variant: » TypeScript
Scaffolding project in D:\Repos\vite-project...
Done. Now run:
cd vite-project
yarn
yarn dev
➜ Repos cd .\vite-project\
➜ vite-project yarn set version canary
➤ YN0000: Downloading https://repo.yarnpkg.com/4.0.0-rc.50/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.0.0-rc.50.cjs
➤ YN0000: Done in 0s 596ms
➜ vite-project yarn
➤ YN0000: · Yarn 4.0.0-rc.49
➤ YN0000: ┌ Resolution step
➤ YN0085: │ + @types/react-dom@npm:18.2.7, @types/react@npm:18.2.21, @typescript-eslint/eslint-plugin@npm:6.4.1, @typescript-eslint/parser@npm:6.4.1, @vitejs/plugin-react@npm:4.0.4, eslint-plugin-react-hooks@npm:4.6.0, eslint-plugin-react-refresh@npm:0.4.3, eslint@npm:8.47.0, and 302 more
➤ YN0000: └ Completed in 4s 325ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ 18 packages were added to the cache (+ 8.96 MiB).
➤ YN0000: └ Completed in 1s 60ms
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ esbuild@npm:0.18.20 must be built because it never has been before or the last one failed
➤ YN0000: └ Completed in 0s 735ms
➤ YN0000: · Done with warnings in 6s 156ms
➜ vite-project yarn dev
VITE v4.4.9 ready in 451 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h to show help
X [ERROR] Could not read from file: D:/Repos/vite-project/.yarn/__virtual__/react-dom-virtual-9383f81a43/7/C:/Users/jeiea/AppData/Local/Yarn/Berry/cache/react-dom-npm-18.2.0-dd675bca1c-10c0.zip/node_modules/react-dom/client.js
➜ vite-project ✗ yarn up
➤ YN0000: · Yarn 4.0.0-rc.49
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: · Done with warnings in 0s 335ms
➜ vite-project yarn
➤ YN0000: · Yarn 4.0.0-rc.49
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: · Done with warnings in 0s 327ms
➜ vite-project yarn dev
VITE v4.4.9 ready in 452 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h to show help
X [ERROR] Could not read from file: D:/Repos/vite-project/.yarn/__virtual__/react-dom-virtual-9383f81a43/7/C:/Users/jeiea/AppData/Local/Yarn/Berry/cache/react-dom-npm-18.2.0-dd675bca1c-10c0.zip/node_modules/react-dom/client.js
D:\Repos\vite-project\.yarn\unplugged\esbuild-npm-0.18.20-004a76d281\node_modules\esbuild\lib\main.js:1649
let error = new Error(`${text}${summary}`);
^
Error: Build failed with 1 error:
error: Could not read from file: D:/Repos/vite-project/.yarn/__virtual__/react-dom-virtual-9383f81a43/7/C:/Users/jeiea/AppData/Local/Yarn/Berry/cache/react-dom-npm-18.2.0-dd675bca1c-10c0.zip/node_modules/react-dom/client.js
at failureErrorWithLog (D:\Repos\vite-project\.yarn\unplugged\esbuild-npm-0.18.20-004a76d281\node_modules\esbuild\lib\main.js:1649:15)
at D:\Repos\vite-project\.yarn\unplugged\esbuild-npm-0.18.20-004a76d281\node_modules\esbuild\lib\main.js:1058:25
at D:\Repos\vite-project\.yarn\unplugged\esbuild-npm-0.18.20-004a76d281\node_modules\esbuild\lib\main.js:1525:9
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
errors: [
{
detail: undefined,
id: '',
location: null,
notes: [],
pluginName: '',
text: 'Could not read from file: D:/Repos/vite-project/.yarn/__virtual__/react-dom-virtual-9383f81a43/7/C:/Users/jeiea/AppData/Local/Yarn/Berry/cache/react-dom-npm-18.2.0-dd675bca1c-10c0.zip/node_modules/react-dom/client.js'
}
],
warnings: []
}
Node.js v20.5.0
➜ vite-project ✗
I had the same problem and I modified it by adding "enableGlobalCache: false" in ".yarnrc" file. you should attention you should have type="module" in the package.json file
Ironically, global cache was the main reason to enable Yarn PnP to avoid refetching of node-modules.
Turning it off is in fact just renaming node-modules folder to .yarn
On Wed, 6 Mar 2024, 04:58 Niloofar Maleki, @.***> wrote:
I had the same problem and I modified it by adding "enableGlobalCache: false" in ".yarnrc" file. you should attention you should have type="module" in the package.json file
— Reply to this email directly, view it on GitHub https://github.com/evanw/esbuild/issues/3131#issuecomment-1979441036, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVDQIKGHCV7RYEXOASBOE3YWYITFAVCNFSM6AAAAAAYM2L5AWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZZGQ2DCMBTGY . You are receiving this because you authored the thread.Message ID: @.***>
I had the same problem and I modified it by adding "enableGlobalCache: false" in ".yarnrc" file. you should attention you should have type="module" in the package.json file
You just saved me. Thanks!
Hi, I'm trying to active PnP mode for Yarn, but Esbuild (0.17.19) fails to resolve node modules. Windows OS. Here is the log snippet, demonstrating the issue:
Last two lines show, that Esbuild failed to properly calculate the Yarn cache path (Failed to resolve "D:\C:\) If I move Yarn cache to drive D:, error looks similar Failed to resolve "D:\D:\