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

Usage in electron #106

Closed
HulioEglesias opened this issue Feb 16, 2020 · 10 comments
Closed

Usage in electron #106

HulioEglesias opened this issue Feb 16, 2020 · 10 comments
Labels
question Further information is requested

Comments

@HulioEglesias
Copy link

When I try to start by electron, I got an error
image

@s1hofmann
Copy link
Member

s1hofmann commented Feb 16, 2020

Hi @HulioEglesias, thanks for reaching out!

Could you please provide additional info regarding your setup?

  • Which Windows version are you one?
  • Which Electron version are you using?
  • Could you provide a little sample project / repo so I can get started quickly?

Best regards

Simon

@s1hofmann s1hofmann added the question Further information is requested label Feb 17, 2020
@HulioEglesias
Copy link
Author

HulioEglesias commented Feb 17, 2020

Windows 10 version 1809(build 17763.1039)
Electron 7.1.11 (abi 75)
Node 12.15.0
Here is example: https://mega.nz/#!QbghBCTb!EavTn8q0IMl6_IhUo0T7QTrQGS0Ml-hu9_BdbKKrRl
For start, you need to have an electron and for start program use electron .

@s1hofmann
Copy link
Member

s1hofmann commented Feb 17, 2020

Would it be possible to provide the sample application in a repository?

@HulioEglesias Tried to use your download link, but it does not work.

@bluedarker
Copy link

I have same error

Error: A dynamic link library (DLL) initialization routine failed.
\\?\c:\workspace\electron-quick-start\node_modules\@nut-tree\libnut-win32\build\Release\libnut.node
    at process.func (electron/js2c/asar.js:140:31)
    at process.func [as dlopen] (electron/js2c/asar.js:140:31)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1016:18)
    at Object.func (electron/js2c/asar.js:140:31)
    at Object.func [as .node] (electron/js2c/asar.js:140:31)
    at Module.load (internal/modules/cjs/loader.js:816:32)
    at Module._load (internal/modules/cjs/loader.js:728:14)
    at Module._load (electron/js2c/asar.js:717:26)
    at Function.Module._load (electron/js2c/asar.js:717:26)
    at Module.require (internal/modules/cjs/loader.js:853:19)

with Electron quick start example
obtain this error only require @nut-tree/nut-js

below is my change code in main.js

const {app, BrowserWindow,ipcMain} = require('electron')
const path = require('path')
const {
  mouse,
  left,
  right,
  up,
  down
} = require('@nut-tree/nut-js');
function createWindow () {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      preload: path.join(__dirname, 'preload.js')
    }
  })

this is error screenshot
image

and my env

Windows 10 version 1809(build 17763.1158)
Electron 8.2.3
node 12.13.0

@s1hofmann
Copy link
Member

Hi @bluedarker,

nut.js uses node addons which would have to be re-built for usage with Electron, see Electron docs.

I did not yet spend time on this, but it would require additional build configs for multiple modules.
Can't promise when I'll find time to look into it, but I'll try to do so.

As always, contributions are very welcome! :)

Best regards

Simon

@s1hofmann
Copy link
Member

s1hofmann commented Apr 29, 2020

Hi @bluedarker and @HulioEglesias,

I published a next release of nut.js which comes with Electron compatible bindings.
Works well with electron-rebuild

Feel free to give it a try and let me know!

Sample:

npm i @nut-tree/nut-js@next
npm i -D electron-rebuild

npx electron-rebuild
npm start

@bluedarker
Copy link

@s1hofmann Thank you so much for you help and contribution, I will make a try and let you know the result within this week.

@bluedarker
Copy link

@s1hofmann
I have tried several times and the same problem with Electron quick start example still exists.

I have tried through different way, including electron-rebuild, electron-builder, node-gyp build and re-init after rm node_modules folder, same thing happened.

I know little about native module, it seems to me that rebuilding @nut-tree\libnut-win32\build\Release\libnut.node is needed. But there is no install.js provided in @nut-tree\libnut-win32.

Any of your replay is very much appreciated.

Could you provide me your ENV for my reference? Following is my ENV:

Windows 10 version 1809(build 17763.1158)
Electron 8.2.3
node 12.13.0

@s1hofmann
Copy link
Member

s1hofmann commented May 5, 2020

Hi @bluedarker,

I just set up a Windows VM and unfortunately, I can confirm your problem.
Sorry for the inconvenience, I only ran my test project on my MacBook and a Linux VM, where everything works fine after an electron-rebuild.

Although I'm having an assumption what might cause this problem, I'll have to investigate on it.

Would you mind opening a separate issue for Electron + Windows problems?

Thanks for your input!

Best regards

Simon

Edit: I guess my assumption was right: nodejs/node-addon-api#269 (comment)

@bluedarker
Copy link

Hi @s1hofmann,
Ok, I open this issues on #126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants