-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Main process fail on class & require() of ES Module #1622
Comments
I found a solution. Try to import ES module with dynamic import & use Molunerfinn/PicGo@bcaf255#diff-37b4428dce773957682d86f1b07d973a0c51f7ae7e377383aabd59707852a3fbR61 Hope this would be help UPDATE : I found this solution will cause @nklayman How do we import pure esm module in main process? Such as fix-path |
The same issue with 6th version of |
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
nklayman/vue-cli-plugin-electron-builder/issues/1622 electron/electron/issues/21457 electron/asar/issues/249 Fix desktop applications failing with following error: ``` A JavaScript error occurred in the main process Uncaught Exception: Error [ERR_REQUIRE_ESM]: require() of ES Module /tmp/.mount_privacSXvQfc/resources/app.asar/index.js not supported. index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules. Instead rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /tmp/.mount_privacSXvQfc/resources/app.asar/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead). at f._load (node:electron/js2c/asar_bundle:2:13330) at node:electron/js2c/browser_init:2:123492 at node:electron/js2c/browser_init:2:123695 at node:electron/js2c/browser_init:2:123699 at f._load (node:electron/js2c/asar_bundle:2:13330) ```
@Molunerfinn Did you by any chance find a solution for this? |
Describe the bug
Can't build main process with class.
To Reproduce
Create a ts file with a class in it.
import the class in background.ts
Error
I'm getting this error :
Tried to fix
I tried to set my vue.config.js just like in #204
And now I'm getting this error :
Expected behavior
Main process build without error.
Additional context
My tsconfig.json :
And my vue.config.js :
vue info :
The text was updated successfully, but these errors were encountered: