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.

Error on dev when using aliases (with Yarn Berry)

See original GitHub issue

Describe the bug

Steps to reproduce:

  1. Clone https://github.com/vuejs/vitepress/tree/chore/vite-3
  2. Run pnpm i && pnpm docs-build && pnpm pack
  3. Create new folder with some content in an index.md file.
  4. Run yarn init -2 and then add vitepress from generated tarball.
  5. 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. With beta.7 the errors were slightly different than beta.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

https://pastebin.com/AZJgi5qH

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
patak-devcommented, Jul 10, 2022

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 🎉

1reaction
brc-ddcommented, Jul 10, 2022

Maybe you should add it in node/plugin.ts? I

Yeah this works!

Read more comments on GitHub >

github_iconTop 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 >

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