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

Using native modules #78

Closed
warpdesign opened this issue Nov 3, 2019 · 1 comment
Closed

Using native modules #78

warpdesign opened this issue Nov 3, 2019 · 1 comment

Comments

@warpdesign
Copy link
Owner

warpdesign commented Nov 3, 2019

Some little problems trying to use native modules...

drivelist

Native module drivelist (or one of its deps) appears to use eval(). Changing the Content-Security-Policy as is fixes the problem, but we don't want this:

    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval'">

electron-rebuild (dev mode)

The drivelist native module has to be rebuilt: electron-rebuild can do that, but it places the drivelist.node build file in node_modules/drivelist/build/darwin-x64-64/drivelist.node and the dev electron doesn't look there so do not find the file.

Manually copying it in one of the searchpath (eg. build/) fixes the problem.

On Windows, the module has first to be rebuilt using:

npm install --save-dev electron-rebuild

# Every time you run "npm install", run this
./node_modules/.bin/electron-rebuild

# On Windows if you have trouble, try:
.\node_modules\.bin\electron-rebuild.cmd

And then the file found inside node_modules\drivelist\bin\win32-x64-64\drivelist.node has to be copied into build.

electron-rebuild (packaged mode)

Built app won't include the built native module and at runtime, following error will appear:

Uncaught (in promise) TypeError: Cannot read property 'indexOf' of undefined

The problem appears to be in bindings or electron-builder, I'm not sure where to look.

Bug opened in bindings: TooTallNate/node-bindings#54

Update: the problem is actually related to the webpack's optimizer that strips some code. See: TooTallNate/node-bindings#61 (comment)

@warpdesign
Copy link
Owner Author

Created a page in the wiki.

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

1 participant