Electron can't find module if this module imported from npm workspaces
See original GitHub issue- Version: 22.10.5
- Electron Version: 12.0.1
- Electron Type (current, beta, nightly):current
- Target: Windows 10 x64
Description
Electron can’t find module if this module imported from npm workspaces. I guess the reason is that there is no package-lock.json
file in the packed application.
Repo with reproduction: https://github.com/cawa-93/electron-builder-issue.
Steps to reproduce
- Clone repo
- Install electron and electron-builder:
npm ci
- Try run in Node:
Expected output:node /path/to/electron-builder-issue/packages/main/dist/index.cjs
/path/to/electron-builder-issue/packages/renderer/dist/index.html
- Build Electron app:
npm run build
- Try run in Electron:
Expected output:/path/to/electron-builder-issue/dist/win-unpacked/vite-electron-builder.exe
Actual behaver: Electron throw Error:/path/to/electron-builder-issue/dist/win-unpacked/resources/app/packages/renderer/dist/index.html
Can not find module "@packages/renderer"
- Try to fix
- Go to
cd /path/to/electron-builder-issue/dist/win-unpacked/resources/app
npm install
- Repeat Step 5.
- Go to
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Cannot find module 'fs/promises' Electron JS - Stack Overflow
I realized that trying to fix another issue, I deleted the node_modules folder and the package-lock.json file, then run the npm install ...
Read more >electron-packager is not bundling the Node modules listed in ...
Runs fine with npm, but fails after packing with the "Cannot Find Module" error. No modules are in resources/app/node_modules/, only one folder ...
Read more >Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package /...
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
When you get the “cannot find module” error, or “module not found”, it means you've not installed the package you're trying to use....
Read more >next-transpile-modules - npm
The way to fix it is easy, and it is what you should always do: install your dependencies with npm ci ("clean install")...
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
I think issue is that electron-builder somehow modifies package.json.
I see your twit… Have you tried PNPM workspace instead of NPM 😉?