electron-builder: Node module not being found in packaged app

When I try to package my electron app, I keep getting:

enter image description here

The vectordb node module requires the @lancedb/vectordb-darwin-arm64, however I have both added in my package.json. I’m using React with Webpack too but it’s working when running so I don’t think it’s a Webpack issue (though could be)

I have two package.jsons, one under release and one under the root (the react-electron-boilerplate just came like this):

enter image description here

In my release/app/package.json: I have the right dependencies:

"dependencies": {
"@lancedb/vectordb-darwin-arm64": "^0.3.11",
"electron-debug": "^3.2.0",
"electron-updater": "^6.1.7",
"openai": "^4.24.1",
"source-map-support": "^0.5.21",
"uuid": "^9.0.1",
"vectordb": "^0.4.1"

}

My build configuration is like so:

"build": {
"productName": "ElectronReact",
"appId": "org.erb.ElectronReact",
"asar": true,
"asarUnpack": "**\\*.{node,dll}",
"afterSign": ".erb/scripts/notarize.js",
"mac": {
  "target": {
    "target": "default",
    "arch": [
      "arm64"
    ]
  },
  "type": "distribution",
  "hardenedRuntime": true,
  "entitlements": "assets/entitlements.mac.plist",
  "entitlementsInherit": "assets/entitlements.mac.plist",
  "gatekeeperAssess": false
},
"dmg": {
  "contents": [
    {
      "x": 130,
      "y": 220
    },
    {
      "x": 410,
      "y": 220,
      "type": "link",
      "path": "/Applications"
    }
  ]
},
"win": {
  "target": [
    "nsis"
  ]
},
"linux": {
  "target": [
    "AppImage"
  ],
  "category": "Development"
},
"directories": {
  "app": "release/app",
  "buildResources": "assets",
  "output": "release/build"
},
"extraResources": [
  "./assets/**"
],
"includeSubNodeModules": true,
"publish": {
  "provider": "github",
  "owner": "electron-react-boilerplate",
  "repo": "electron-react-boilerplate"
}

},

VectorDB is supposed to install the missing dependency on its own if its not there, but on a packaged app, this isn’t working for some reason either too.

I’ve tried a lot of other things from other SO questions but none of them worked:

  • Using the files or extraFiles to specify copying over node_modules/@lancedb/vectordb-darwin-arm64 to the package folder
  • Adding both dependencies to the root package.json
  • Setting build target to just default and then seeing if vectordb installs it on its own
  • Electron Forge: but I ended up getting an asar error about a link reference pointing outside of node_modules that kept failing

Leave a Comment