electron-builder: Cannot find module napi-v6-darwin-unknown-x64 in the universal app
- Electron-Builder Version: 24.0.0
- Node Version: 16.15.1
- Electron Version:23.1.3
- Electron Type (current, beta, nightly): current
- Target: Universal
- I’m trying to build our Electron app as a Universal (I’m using this command
electron-builder --config ./electron-builder.json --mac --universal), but I got this error in the run time for the app after building it from the M1 machine with XCode v14.2 (I’m usingsqlite3 v5.1.4)
An unexpected error occurred at startup
09/03/2023, 17:06:04 EET Error details:
name: Error,
message: Cannot find module '/Applications/myApp.app/Contents/Resources/app-x64.asar/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-x64/node_sqlite3.node'
Require stack:
- /Applications/myApp.app/Contents/Resources/app-x64.asar/node_modules/sqlite3/lib/sqlite3-binding.js
- /Applications/myApp.app/Contents/Resources/app-x64.asar/node_modules/sqlite3/lib/sqlite3.js
- /Applications/myApp.app/Contents/Resources/app-x64.asar/dist/main-bundle.js
- /Applications/myApp.app/Contents/Resources/app.asar/index.js
- ,
-
Here is
myApp.app/Contents/Resources directoryin theApplicationpath
-
As you see there is no
napi-v6-darwin-unknown-x64insideapp-x64.asar.unpackedwhile there isnapi-v{napi_build_version}-darwin-unknown-x64 -
When I tried to build the app from an Intel machine (Xcode
v14.2) there isnapi-v6-darwin-unknown-x64insideapp-x64.asar.unpackedwhile there is nonapi-v6-darwin-unknown-arm64insideapp-arm64.asar.unpacked(napi-v{napi_build_version}-darwin-unknown-arm64exists) -
Here is
electron-builder.jsoncontents:
{
"appId": "com.myapp.myApp",
"productName": "mayApp",
"buildVersion": "2.1.0",
"compression": "normal",
"directories": {
"app": "./rb-services",
"buildResources": "./setup/build",
"output": "./compile"
},
"afterSign": "./notarize.js",
"asarUnpack": ["**/*.node"],
"mac": {
"category": "public.app-category.business",
"icon": "./setup/build/icon.icns",
"hardenedRuntime": true,
"mergeASARs": false,
"entitlements": "./setup/build/entitlements.mac.plist",
"entitlementsInherit": "./setup/build/entitlements.mac.plist",
"files": [
"**/*",
"!**/*.ts",
"!**/*.tlog",
"!**/*.log",
"!**/*.exp",
"!**/*.lib",
"!**/*.iobj",
"!**/*.obj",
"!**/*.ipdb",
"!**/*.pdb",
"!**/*.ilk",
"!**/*.map",
"!**/*.vcxproj*",
"!**/*.lastbuildstate",
"!**/*config.gypi",
"!**/*binding.gyp",
"!**/*Dockerfile",
"!**/*tsconfig.json",
"!**/patches/*.patch",
"!**/node_modules/**/*/doc/**/*",
"!**/node_modules/**/*/docs/**/*",
"!**/node_modules/sqlite3/build/**/*",
"!**/node_modules/sqlite3/build-tmp-napi-v6/**/*",
"!**/node_modules/**/*.{mk,a,o,h}",
"!src"
],
"dmg": {
"title": "mayApp",
"background": "./setup/build/myApp.png",
"iconSize": 90,
"contents": [
{ "x": 448, "y": 300, "type": "link", "path": "/Applications" },
{ "x": 192, "y": 300, "type": "file" }
],
"window": {
"height": 500
}
},
"appx": {
"publisherDisplayName": "myApp"
},
"electronVersion": "23.1.3",
"buildDependenciesFromSource": true,
"nodeGypRebuild": false,
"npmRebuild": true,
"extends": null
}
** Update: The issue doesn’t exist when using electron-builder v23.6.0, it seems related to the latest version (24.0.0)
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 22
Updated
@electron/rebuilddependency so that you don’t need to use a custom patch-package approach. electron-builder 24.3.0 has the fixWait, why is it not leveraging
build/Release/node_sqlite3.nodein each of the relative unpacked asars?I think the extensions “.mk”, “.a”, “.o”, and “.h” are used for make files, static libraries, object files, and header files, respectively. Each of these file types serves a specific purpose in the process of compiling and linking source code, but as I saw no need to be in the generated app (at least in my project),
I guess
electron/rebuildormakedoesn’t handle paths with spaces? Try removing the empty space fromTest projectsand replace with hypen?I can prob take a look at the repro repo later today or this weekend.