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

After Hot-Reload: Uncaught Error: Cannot find module 'undefined #2760

Closed
3 tasks done
Nestoro opened this issue Mar 8, 2022 · 1 comment
Closed
3 tasks done

After Hot-Reload: Uncaught Error: Cannot find module 'undefined #2760

Nestoro opened this issue Mar 8, 2022 · 1 comment

Comments

@Nestoro
Copy link

Nestoro commented Mar 8, 2022

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

6.0.0-beta.63

Electron version

16.0.8

Operating system

Windows 10

Last known working Electron Forge version

6.0.0-beta.63

Expected behavior

After Hot-Reloading during electron-forge start the installed node-modules should still be findable. and the variable in the path should not turn into undefined.

Actual behavior

I've installed better-sqlite3 and wrote some code using it. Then I started up the application using electron-forge start and everything just worked. Then I made an adjustment and the app reloaded, but stopped running with this error in dev tools:

node:internal/modules/cjs/loader:940 Uncaught Error: Cannot find module 'undefinedbuild/Release/better_sqlite3.node'
Require stack:
- electron/js2c/renderer_init
    at Module._resolveFilename (node:internal/modules/cjs/loader:940)
    at Function.o._resolveFilename (node:electron/js2c/renderer_init:33)
    at Module._load (node:internal/modules/cjs/loader:785)
    at Function.c._load (node:electron/js2c/asar_bundle:5)
    at Function.o._load (node:electron/js2c/renderer_init:33)
    at Module.require (node:internal/modules/cjs/loader:1012)
    at require (node:internal/modules/cjs/helpers:94)
    at new Database (database.js?4c26:48)
    at openDB (openDB.ts?4563:7)
    at getIndex (getIndex.ts?af7b:8)

After closing it and reissuing electron-forge start it proceeded to run as intended, Until I reload once. then this error messages appears again.

When I reload the app some variable seems to be set to undefined and the module discontinues to be findable

Steps to reproduce

  1. follow this guide to setup electron with typescript and react
  2. Install better-sqlite3
  3. add this to a .ts file (I do not know if it makes a difference, for this scenario, having it in .ts or .tsx, i do have it in a .ts file)
import Database from 'better-sqlite3';

export const openDB = () => {
	const db = new Database('test.db', {});
	return db;
};
  1. run electron-forge start
  2. make a change to trigger Hot-Reload

Additional information

No response

@Nestoro Nestoro added the bug label Mar 8, 2022
@malept
Copy link
Member

malept commented Mar 8, 2022

Duplicate of #2412

@malept malept marked this as a duplicate of #2412 Mar 8, 2022
@malept malept closed this as completed Mar 8, 2022
@malept malept added duplicate and removed bug labels Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants