Error on dev when using aliases (with Yarn Berry)
See original GitHub issueDescribe the bug
Steps to reproduce:
- Clone https://github.com/vuejs/vitepress/tree/chore/vite-3
- Run
pnpm i && pnpm docs-build && pnpm pack
- Create new folder with some content in an
index.md
file. - Run
yarn init -2
and then addvitepress
from generated tarball. - Run
yarn vitepress dev
and open the server URL.
Additional Context:
@sitedata
is an alias defined here: https://github.com/vuejs/vitepress/blob/chore/vite-3/src/node/alias.ts#L15 – it resolves to/@siteData
which is sort of a virtual file.vite@3.0.0-beta.5
works fine. Withbeta.7
the errors were slightly different thanbeta.9
.- The error doesn’t occur with other package managers. (Only Yarn v2/v3 has this issue.)
- Setting
optimizeDeps.exclude: [ 'vitepress' ]
doesn’t work. vitepress build
works fine.
Reproduction
System Info
System:
OS: Windows 10 10.0.25151
Binaries:
Node: 16.15.0 - C:\Program Files\nodejs\node.EXE
npm: 8.5.5 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@vitejs/plugin-vue: ^3.0.0-beta.1 => 3.0.0-beta.1
vite: ^3.0.0-beta.9 => 3.0.0-beta.9
Used Package Manager
yarn
Logs
Without debug:
Click to expand!
vitepress v1.0.0-alpha.4
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
✘ [ERROR] [plugin vite:dep-pre-bundle] ENOENT: no such file or directory, open 'C:\@siteData'
.yarn/cache/vitepress-file-99ecbdfd2e-e651c85511.zip/node_modules/vitepress/dist/client/app/data.js:2:21:
2 │ import siteData from '@siteData';
╵ ~~~~~~~~~~~
This error came from the "onLoad" callback registered here:
.yarn/unplugged/esbuild-npm-0.14.48-d0430cb883/node_modules/esbuild/lib/main.js:843:22:
843 │ let promise = setup({
╵ ^
at setup (file:///C:/Users/brc-dd/Desktop/foo/.yarn/__virtual__/vite-virtual-e9a9a112c0/0/cache/vite-npm-3.0.0-beta.9-2a0af96c72-287ead2b4c.zip/node_modules/vite/dist/node/chunks/dep-58325dc2.js:34737:23)
at handlePlugins (C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:843:23)
at Object.buildOrServe (C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1137:7)
at C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:2085:17
at new Promise (<anonymous>)
at Object.build (C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:2084:14)
at build (C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1931:51)
at runOptimizeDeps (file:///C:/Users/brc-dd/Desktop/foo/.yarn/__virtual__/vite-virtual-e9a9a112c0/0/cache/vite-npm-3.0.0-beta.9-2a0af96c72-287ead2b4c.zip/node_modules/vite/dist/node/chunks/dep-58325dc2.js:36902:26)
at async optimizeNewDeps (file:///C:/Users/brc-dd/Desktop/foo/.yarn/__virtual__/vite-virtual-e9a9a112c0/0/cache/vite-npm-3.0.0-beta.9-2a0af96c72-287ead2b4c.zip/node_modules/vite/dist/node/chunks/dep-58325dc2.js:36268:16)
6:08:41 PM [vite] error while updating dependencies:
Error: Build failed with 1 error:
.yarn/cache/vitepress-file-99ecbdfd2e-e651c85511.zip/node_modules/vitepress/dist/client/app/data.js:2:21: ERROR: [plugin: vite:dep-pre-bundle] ENOENT: no such file or directory, open 'C:\@siteData'
at failureErrorWithLog (C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1605:15)
at C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1251:28
at runOnEndCallbacks (C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1034:63)
at buildResponseToResult (C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1249:7)
at C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1358:14
at C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:666:9
at handleIncomingPacket (C:\Users\brc-dd\Desktop\foo\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:763:9)
at Socket.readFromStdout (C:\Users\brc-dd\Desktop\foo\.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:315:12)
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- 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.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
JavaScript package managers compared: npm, Yarn, or pnpm?
Use the yarn set version command to upgrade to the latest modern version: $ yarn set version berry. However, the recommended way to...
Read more >yarn install
Yarn will not install any package listed in devDependencies if the NODE_ENV environment variable is set to production . Use this flag to...
Read more >Update previously patched package with Yarn Berry
I have patched a package (@pkg/pkg) with the command yarn patch @pkg/pkg and I am using it as a devDependency with the patch:...
Read more >Babel-plugin-7-webpack-alias - npm.io
The objective of this plugin is to provide support for yarn 2 (AKA berry), ava , and webpack configs that are defined as...
Read more >vscode tsconfig cannot find module - Feudo 43
Webpack needs to know physical paths that map to the aliases we want to create. ... Jan 20, 2022 · VSCode cannot find...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is strange that the configs didn’t get merged, I would assume that it should have worked if you placed where you did first. Another issue to report if you find a minimal repro to share. Great to see this working then! Back on track to release Vite 3 this week 🎉
Yeah this works!