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.

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

  1. Clone repo
  2. Install electron and electron-builder: npm ci
  3. Try run in Node:
    node /path/to/electron-builder-issue/packages/main/dist/index.cjs
    
    Expected output:
    /path/to/electron-builder-issue/packages/renderer/dist/index.html
    
  4. Build Electron app: npm run build
  5. Try run in Electron:
    /path/to/electron-builder-issue/dist/win-unpacked/vite-electron-builder.exe
    
    Expected output:
    /path/to/electron-builder-issue/dist/win-unpacked/resources/app/packages/renderer/dist/index.html
    
    Actual behaver: Electron throw Error: Can not find module "@packages/renderer"
  6. Try to fix
    1. Go to cd /path/to/electron-builder-issue/dist/win-unpacked/resources/app
    2. npm install
    3. Repeat Step 5.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
develarcommented, Mar 15, 2021

I think issue is that electron-builder somehow modifies package.json.

1reaction
develarcommented, Mar 15, 2021

I see your twit… Have you tried PNPM workspace instead of NPM 😉?

Read more comments on GitHub >

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

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