Troubleshooting
Troubleshooting common issues with Electron Router DOM
If you're having trouble with Electron Router DOM, here are some common issues and solutions.
Distribution
A JavaScript error occurred in the main process -> Error: Cannot find module 'XXX'
The following solution is from Electron Vite docs, but it's the same for most of the Electron apps:
Dependent modules are not packaged into the application. To solve this:
- If the related module is installed in
devDependencies, please reinstall it independencies. This is because packaging tools (e.g.electron-builder,electron-forge) usually exclude modules indevDependencies. - If you are using the
pnpm package manager, you’ll need to add a file.npmrcwithshamefully-hoist=truein project root directory (in order for your dependencies to be bundled correctly). Also, you need to deletenode_modulesandpnpm-lock.yaml, then reinstall the modules. Of course you can switch to other package manager (e.g.npm,yarn) to avoid this problem.