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

Error: vite-plugin-electron-renderer tried to access esbuild, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound. #27

Open
nelsonni opened this issue Oct 13, 2023 · 2 comments

Comments

@nelsonni
Copy link

The yarn create electron-vite electron-vite-project command in the README results in a non-runnable Electron application. After installing dependencies through yarn (or yarn install), and attempting to launch the dev mode via yarn dev, I get the following error:

error when starting dev server:
Error: vite-plugin-electron-renderer tried to access esbuild, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: esbuild (via "esbuild/package.json")
Required by: vite-plugin-electron-renderer@npm:0.14.5 (via /Users/nelsonni/Workspace/electron-vite-project/.yarn/cache/vite-plugin-electron-renderer-npm-0.14.5-3e9f36a2d1-50628357bc.zip/node_modules/vite-plugin-electron-renderer/dist/index.mjs)

The full log is included below:

yarn create electron-vite electron-vite-projectYN0000: ┌ Resolution stepYN0000: └ CompletedYN0000: ┌ Fetch stepYN0000: └ CompletedYN0000: ┌ Link stepYN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimentalYN0007: │ create-electron-vite@npm:0.4.0 must be built because it never has been before or the last one failedYN0000: └ Completed in 1s 55msYN0000: Done with warnings in 1s 201msProject template: › React

Scaffolding project in /Users/nelsonni/Workspace/electron-vite-project...

Done. Now run:

  cd electron-vite-project
  yarn
  yarn devcd electron-vite-projectyarnYN0000: ┌ Resolution stepYN0032: │ node-addon-api@npm:1.7.2: Implicit dependencies on node-gyp are discouragedYN0032: │ fsevents@npm:2.3.3: Implicit dependencies on node-gyp are discouragedYN0000: └ Completed in 5s 248msYN0000: ┌ Fetch stepYN0013: │ yallist@npm:4.0.0 can't be found in the cache and will be fetched from the remote registryYN0013: │ yargs-parser@npm:21.1.1 can't be found in the cache and will be fetched from the remote registryYN0013: │ yargs@npm:17.7.2 can't be found in the cache and will be fetched from the remote registryYN0013: │ yauzl@npm:2.10.0 can't be found in the cache and will be fetched from the remote registryYN0013: │ yocto-queue@npm:0.1.0 can't be found in the cache and will be fetched from the remote registryYN0000: └ Completed in 0s 563msYN0000: ┌ Link stepYN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimentalYN0007: │ electron@npm:26.4.0 must be built because it never has been before or the last one failedYN0007: │ esbuild@npm:0.18.20 must be built because it never has been before or the last one failedYN0000: └ Completed in 1s 940msYN0000: Done with warnings in 7s 793msyarn dev
error when starting dev server:
Error: vite-plugin-electron-renderer tried to access esbuild, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: esbuild (via "esbuild/package.json")
Required by: vite-plugin-electron-renderer@npm:0.14.5 (via /Users/nelsonni/Workspace/electron-vite-project/.yarn/cache/vite-plugin-electron-renderer-npm-0.14.5-3e9f36a2d1-50628357bc.zip/node_modules/vite-plugin-electron-renderer/dist/index.mjs)

    at makeError (/Users/nelsonni/Workspace/electron-vite-project/.pnp.cjs:13905:34)
    at resolveToUnqualified (/Users/nelsonni/Workspace/electron-vite-project/.pnp.cjs:15582:21)
    at Object.resolveToUnqualified (/Users/nelsonni/Workspace/electron-vite-project/.pnp.cjs:15764:26)
    at resolve$1 (file:///Users/nelsonni/Workspace/electron-vite-project/.pnp.loader.mjs:1977:31)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:835:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
    at link (node:internal/modules/esm/module_job:76:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@nelsonni
Copy link
Author

nelsonni commented Oct 13, 2023

The npm and pnpm versions do not have this issue, so it appears to be isolated to using yarn.

@caoxiemeihao
Copy link
Member

Maybe the following example is better for you.
https://github.com/caoxiemeihao/electron-vite-samples/tree/main/serialport-renderer-process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants