Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All build scripts fail when creating a new vite project in a Yarn monorepo #10652

Closed
7 tasks done
hansoksendahl opened this issue Oct 26, 2022 · 2 comments · Fixed by #10683
Closed
7 tasks done

All build scripts fail when creating a new vite project in a Yarn monorepo #10652

hansoksendahl opened this issue Oct 26, 2022 · 2 comments · Fixed by #10683
Labels
p4-important Violate documented behavior or significantly improves performance (priority) regression The issue only appears after a new release

Comments

@hansoksendahl
Copy link

Describe the bug

I created a Vite project inside a monorepo managed with Yarn workspaces. I created a new Vite project (react-ts template) inside the monorepo, installed its dependencies, and ran it with yarn dev.

I have tried with vue-ts, react-ts, and vanilla-ts. The only config that worked was vanilla-ts It appears that any template that produces a vite.config.ts file fails.

Expected

Should run Vite project dev server.

Actual

Fails with a number of errors

✘ [ERROR] [plugin externalize-deps] Cannot find package 'vite' imported from /Users/hans/Code/nodeland/test/packages/vite-project/vite.config.ts

    ../../.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1327:27:
      1327 │         let result = await callback({
           ╵                            ^
✘ [ERROR] [plugin externalize-deps] Cannot find package '@vitejs/plugin-react' imported from /Users/hans/Code/nodeland/test/packages/vite-project/vite.config.ts

    ../../.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1327:27:
      1327 │         let result = await callback({
           ╵                            ^

Reproduction

https://github.com/hansoksendahl/vite-bug

Steps to reproduce

  • $ mkdir [REPO_NAME]
  • $ cd [REPO_NAME]
  • $ yarn init -2
  • $ mkdir packages
  • Add the following to package.json
    {
      "workspaces": [
        "packages/*"
      ]
    }
  • $ cd packages
  • $ yarn create vite vite-project --template react-ts
  • $ cd vite-project
  • $ yarn
  • $ yarn dev

System Info

System:
    OS: macOS 12.5.1
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 103.40 MB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.18.0 - ~/.nvm/versions/node/v16.18.0/bin/node
    Yarn: 3.2.4 - ~/.nvm/versions/node/v16.18.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v16.18.0/bin/npm
  Browsers:
    Chrome: 106.0.5249.119
    Safari: 15.6.1

Used Package Manager

yarn

Logs

Click to expand!
❯ yarn vite --debug
✘ [ERROR] [plugin externalize-deps] Cannot find package 'vite' imported from /Users/hans/Code/nodeland/test/packages/vite-project/vite.config.ts

    ../../.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1327:27:
      1327 │         let result = await callback({
           ╵                            ^

    at new NodeError (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:508:5)
    at packageResolve (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:1719:9)
    at moduleResolve (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:1776:20)
    at defaultResolve (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:1924:15)
    at resolve$4 (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:1962:12)
    at file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:65687:46
    at requestCallbacks.on-resolve (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1327:28)
    at handleRequest (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:697:19)
    at handleIncomingPacket (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:719:7)
    at Socket.readFromStdout (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:647:7)

  This error came from the "onResolve" callback registered here:

    ../../.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1251:20:
      1251 │       let promise = setup({
           ╵                     ^

    at setup (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:65670:27)
    at handlePlugins (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1251:21)
    at buildOrServeImpl (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:942:5)
    at Object.buildOrServe (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:750:5)
    at /Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:2085:17
    at new Promise (<anonymous>)
    at Object.build (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:2084:14)
    at build (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1931:51)
    at bundleConfigFile (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:65648:26)

  The plugin "externalize-deps" was triggered by this import

    vite.config.ts:1:363:
      1 │ ...ig.ts";const __vite_injected_original_import_meta_url = "file:///Users/hans/Code/nodeland/test/packages/vite-project/vite.config.ts";import { defineConfig } from 'vite'
        ╵                                                                                                                                                                      ~~~~~~

✘ [ERROR] [plugin externalize-deps] Cannot find package '@vitejs/plugin-react' imported from /Users/hans/Code/nodeland/test/packages/vite-project/vite.config.ts

    ../../.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1327:27:
      1327 │         let result = await callback({
           ╵                            ^

    at new NodeError (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:508:5)
    at packageResolve (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:1719:9)
    at moduleResolve (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:1776:20)
    at defaultResolve (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:1924:15)
    at resolve$4 (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:1962:12)
    at file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:65687:46
    at requestCallbacks.on-resolve (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1327:28)
    at handleRequest (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:697:19)
    at handleIncomingPacket (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:719:7)
    at Socket.readFromStdout (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:647:7)

  This error came from the "onResolve" callback registered here:

    ../../.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1251:20:
      1251 │       let promise = setup({
           ╵                     ^

    at setup (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:65670:27)
    at handlePlugins (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1251:21)
    at buildOrServeImpl (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:942:5)
    at Object.buildOrServe (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:750:5)
    at /Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:2085:17
    at new Promise (<anonymous>)
    at Object.build (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:2084:14)
    at build (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1931:51)
    at bundleConfigFile (file:///Users/hans/Code/nodeland/test/.yarn/__virtual__/vite-virtual-1d36e0d65e/0/cache/vite-npm-3.2.0-8a4dc272ca-2b3acfe745.zip/node_modules/vite/dist/node/chunks/dep-61d2428a.js:65648:26)

  The plugin "externalize-deps" was triggered by this import

    vite.config.ts:2:18:
      2 │ import react from '@vitejs/plugin-react'
        ╵                   ~~~~~~~~~~~~~~~~~~~~~~

failed to load config from /Users/hans/Code/nodeland/test/packages/vite-project/vite.config.ts
error when starting dev server:
Error: Build failed with 2 errors:
../../.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1327:27: ERROR: [plugin: externalize-deps] Cannot find package '@vitejs/plugin-react' imported from /Users/hans/Code/nodeland/test/packages/vite-project/vite.config.ts
../../.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1327:27: ERROR: [plugin: externalize-deps] Cannot find package 'vite' imported from /Users/hans/Code/nodeland/test/packages/vite-project/vite.config.ts
    at failureErrorWithLog (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1566:15)
    at /Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1024:28
    at runOnEndCallbacks (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1438:61)
    at buildResponseToResult (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1022:7)
    at /Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:1134:14
    at responseCallbacks.<computed> (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:671:9)
    at handleIncomingPacket (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/Users/hans/Code/nodeland/test/.yarn/unplugged/esbuild-npm-0.15.12-0d999cf382/node_modules/esbuild/lib/main.js:647:7)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)

Validations

@sapphi-red sapphi-red added the regression The issue only appears after a new release label Oct 26, 2022
@jj811208
Copy link

I used git bisect to find out when this started happening.

It comes from here:
4fd49e6#diff-11e17761d4ecfee8f8fde15c6d79b7bc0260176396a30dfd8e6f6bbaf5af4745

@vtaits
Copy link

vtaits commented Oct 28, 2022

@jj811208

Thank you. My workaround is fix 3.1.8 version. I hope it will be fixed soon.

@sapphi-red sapphi-red added the p4-important Violate documented behavior or significantly improves performance (priority) label Oct 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p4-important Violate documented behavior or significantly improves performance (priority) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants