Search code examples
electronknex.jselectron-forge

Error when launching signed and notarized app - JavaScript error occurred in the main process


When launching an electronjs app that has been osx signed and notarized with electron-forge I get the following error:

Uncaught Exception:
Error: Knex: run
$ npm install sqlite3 --save
dlopen(/var/folders/..., 0x0001): tried: '/var/folders/....' (code signature in <> '.....' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '......' (no such file)

I'm using electron-forge to make the project. Signing and Notarization succeeds. If I do not sign and notarize the application launches and functions properly.


Solution

  • For anyone using electron forge this fixed the error with dlopen(.... different team Ids.

    1. Add entitlements.plist to the root of your project.
    com.apple.security.cs.allow-unsigned-executable-memory com.apple.security.cs.disable-library-validation com.apple.security.cs.allow-jit
    1. In forge.config.js add this to osxSign: optionsForFile: (filePath) => { // Here, we keep it simple and return a single entitlements.plist file. // You can use this callback to map different sets of entitlements // to specific files in your packaged app. return { entitlements: './entitlements.plist' }; }

    https://github.com/electron/notarize/issues/185