eclipse-theia / generator-theia-extension

A Yeoman generator for extensions to the Theia IDE
Other
49 stars 37 forks source link

Electron app error about #195

Closed woung717 closed 7 months ago

woung717 commented 7 months ago

For some unclear reasons, the recent versions of the generator have not resolved the issues I've been encountering related with this issue. I've removed all .browser_modules and node_module directories and executed yarn install. However, this only appears to be effective for the 'Run & Debug "Start Electron Backend"' action. I continue to experience failures with 'yarn build:electron && yarn start:electron' and this remains an ongoing error.

JonasHelming commented 7 months ago

Do you get the exact same error message as before?

woung717 commented 7 months ago

Do you get the exact same error message as before?

Here's the process I followed to reproduce the issue:

  1. yo theia-extension -> selected "widget" and put extension name -> yarn build:electron && yarn start:electron - this works well.
  2. I made changes to some code in the extension directory such as string contents.
  3. npm rebuild (at /electron-app) && yarn build:electron && yarn start:electron - this does not work; it exits immediately.

Moreover, when executing Run&Debug "Start Electron Backend," I received the following error message:

/{ProjectRootDir}/node_modules/.bin/electron ./electron-app/src-gen/backend/electron-main.js --loglevel=debug --hostname=localhost --no-cluster

Debugger listening on ws://127.0.0.1:53702/7956f222-1497-4900-8ef9-b425b5b9d50f
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Debugger listening on ws://127.0.0.1:53705/ceb1780f-9b18-4bd4-941d-d3f6b0a5a131
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Showing main window early
Electron [file]

Positionals:
  file                                                                  [string]

Options:
  --help              Show help                                        [boolean]
  --version           Show version number                              [boolean]
  --electronUserData  The area where the electron main process puts its data
                                                                        [string]

Error: Module did not self-register: '/{ProjectRootDir}/node_modules/drivelist/build/Release/drivelist.node'.
    at process.func [as dlopen] (node:electron/js2c/asar_bundle:2:1822)
    at Module._extensions..node (node:internal/modules/cjs/loader:1259:18)
    at Object.func [as .node] (node:electron/js2c/asar_bundle:2:1822)
    at Module.load (node:internal/modules/cjs/loader:1044:32)
    at Module._load (node:internal/modules/cjs/loader:885:12)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at Module.require (node:internal/modules/cjs/loader:1068:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at bindings (/{ProjectRootDir}/node_modules/bindings/bindings.js:112:48)
    at Object.<anonymous> (/{ProjectRootDir}/node_modules/drivelist/js/index.js:25:27) {
  code: 'ERR_DLOPEN_FAILED'
}
Waiting for the debugger to disconnect...

To handle this, I removed '.browser_modules' and 'node_module' directories and ran yarn install. It helped to some extent as the 'Run&Debug "Start Electron Backend"' started working, but the problematic 'yarn build:electron && yarn start:electron' command remains unresolved.

And if I build/run in wrong way, please let me know. Thank you for your reply.

ps. redacted some of paths

woung717 commented 7 months ago

@JonasHelming I finally figured out how to build the extension and deploy it to the electron app properly. I had to build the extension using npm run build in the extension directory and then run yarn build:electron && yarn start:electron. Previous approaches may have caused problems as I tried to build electron-app directly using npm rebuild in the electron-app directory.

I think it would be good to include some sort of guide to building extensions and deploying to electron-app in the README file or somewhere for newbies. The build commands are different from the Theia project document. (ex. There is no yarn rebuild:electron command in generated extension project)

sdirix commented 7 months ago

Hi @woung717,

You are right. What we are missing is a convenient "build" script in the root which builds all extensions. At the moment the build of the extension is only triggered when executing yarn (via the prepare step) or when executing yarn watch:browser / yarn watch:electron.

The rebuild command is misleading. It's only about the native Node dependencies in node_modules and unrelated to the source code itself.

woung717 commented 7 months ago

@sdirix Thanks for the confirmation. Now I understand the structure of the build scripts. Then yarn prepare (build extensions) -> yarn build:electron && yarn start:electron (build electron app with the built extension) is the standard way to check changes without the watch option?

sdirix commented 7 months ago

Yes, that is how it is set up at the moment. However we should do an improvement so that there is a separate build command for the extensions in addition to prepare.

woung717 commented 7 months ago

Thank you guys, it helps a lot to start with the Theia project. Have a nice day! @JonasHelming @sdirix