I have an app developed in Linux (Xubuntu), when I try to build the app in the Linux it's all fine. but when I build the app for the Windows, It gives me the better-sqlite3.node is not a valid win32 application!
how can I fix this?
You'll need to give some more context about how exactly you're building your app, which commands you're running, which version of Node.js you're using, etc.
Here is my package.json file below:
{
"name": "hadi",
"version": "1.0.0",
"description": "Hadi Software",
"main": "index.js",
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"dist:linux": "electron-packager . Hadi --platform=linux --arch=x64 --out=dist --overwrite",
"dist:win32": "electron-packager . Hadi --platform=win32 --arch=x64 --out=dist --overwrite",
"dist:win32_ia32": "electron-packager . Hadi --platform=win32 --arch=ia32 --out=dist --overwrite",
"postinstall": "electron-builder install-app-deps"
},
"repository": {
"type": "git",
"url": "git+https://github.com/alphamarket/hadi.git"
},
"author": "Dariush Hasanpoor.",
"license": "MIT",
"bugs": {
"url": "https://github.com/alphamarket/hadi/issues"
},
"homepage": "https://github.com/alphamarket/hadi#readme",
"devDependencies": {
"electron": "^4.0.3",
"electron-builder": "^20.38.5",
"electron-debug": "^2.1.0",
"node-sass": "^4.11.0",
"electron-reload": "^1.4.0",
"sass-loader": "^7.1.0"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^5.7.0",
"better-sqlite3": "^5.4.0",
"coffeescript": "^2.3.2",
"compass-mixins": "^0.12.10",
"ejs": "^2.6.1",
"ejs-electron": "^2.0.3",
"electron-middle-sass": "^1.0.2",
"globby": "^9.0.0",
"image-size": "^0.7.1",
"jquery": "^3.3.1",
"materialize-css": "^1.0.0-rc.2"
},
"build": {
"appId": "com.electron.${name}",
"win": {
"target": "nsis"
}
}
}
The command to build my App is yarn dist:win32.
The building OS: Ubuntu 18.04.1 LTS
The target OS: Window-7 x86 | x64
The Node Version: 11.8.0
You can find the project here.
Execute the yarn dist:win32 then copy the built folder at <project_root>/dist/Hadi-win32-x64 to a windows-7 evn. execute the Hadi exe; click on the BIG PURPLE circle. THEN THE PROBLEM WILL SHOW OFF!
You should use Windows x86 OS for building your project because the better-sqlite3 has native dependencies. I use this way for my electron app.
Closing due to inactivity
This may be fixed in v7.0.0.
@JoshuaWise i still have this problem when build windows app on my mac, here is some dependences in my project
"better-sqlite3": "^7.1.1",
"electron": "^8.5.0",
"electron-builder": "^22.8.0",
"webpack": "^4.44.1",
and nodejs version is v14.7.0.
should i have to build windows app on windows OS compulsory?
or there are some other solutions to help me build?
Most helpful comment
You should use Windows x86 OS for building your project because the better-sqlite3 has native dependencies. I use this way for my electron app.