Electron Build fails on Arch Linux unless SQLite version is overridden

I just tried to build the Joplin Electron Client for the first time on a Arch Linux machine, following the instructions in BUILD.md.

On the npm i part, I get the following node-gyp related error:

In file included from ../src/database.cc:3:
../src/database.cc: In static member function ‘static void node_sqlite3::Database::Work_AfterLoadExtension(uv_work_t*)’:
../src/macros.h:91:13: error: no matching function for call to ‘v8::String::Concat(v8::Local<v8::String>, v8::Local<v8::String>)’
   91 |             ),                                                                 \
      |             ^

make: *** [node_sqlite3.target.mk:125: Release/obj.target/node_sqlite3/src/database.o] Error 1
make: Leaving directory '/home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:196:23)
gyp ERR! stack     at ChildProcess.emit (events.js:219:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:274:12)
gyp ERR! System Linux 5.3.11-arch1-1
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3/lib/binding/node-v79-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3/lib/binding/node-v79-linux-x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v79"
gyp ERR! cwd /home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3
gyp ERR! node -v v13.3.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3/lib/binding/node-v79-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3/lib/binding/node-v79-linux-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v79' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/geo/code/joplin/ElectronClient/app/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:219:5)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1027:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:285:5)
node-pre-gyp ERR! System Linux 5.3.11-arch1-1
node-pre-gyp ERR! command "/usr/bin/node" "/home/geo/code/joplin/ElectronClient/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3
node-pre-gyp ERR! node -v v13.3.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3/lib/binding/node-v79-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/home/geo/code/joplin/ElectronClient/app/node_modules/sqlite3/lib/binding/node-v79-linux-x64 --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v79' (1)

I saw the BUILD.md has a section on node-gyp related errors, so I tried that, but the error is the same.
I found this to be very weird because I installed joplin via the AUR before and there it compiles just fine. So I checked out the PKGBUILD of Joplin on AUR and indeed there seems to be a workaround in place for the above issue:

  # Electron App
  cd "${srcdir}/${pkgname}-${pkgver}/ElectronClient/app"

  # NOTE: Manually forcing sqlite 4.0.7 for node v12, remove later on
  npm install sqlite3@4.0.7
  npm install

If I do the above, that is, manually setting sqlite to 4.0.7. (The package.json specifies ^4.0.6). Things compile fine.
Did someone see this before? I have the feeling this is related to the node / node-gyp versions, could someone whose build works just fine share their output of node -v and node-gyp -v? Thanks!

For the arch Linux package support please use the official repo: https://github.com/alfredopalhares/joplin-pkgbuild

Thanks for pointing me there, however the question is not directly related to the Arch Linux package. It’s rather related to the fact I can’t build Joplin by following the BUILD.md instructions. The reason is that probably Joplin is incompatible to the node / node-gyp versions that come installed with Arch Linux (something also hinted at in this issue of the repo you linked to). I didn’t see in any of the development documentation a indication of what node version Joplin is compatible with, hence the ask for the output of node -v and node-gyp -v of someone that achieves building Joplin without modifying the ElectronApp/app/package.json.

My versions on Manjaro (Arch-based distro) that successfully builds joplin.

[marcus@manjaro joplin-docker]$ node -v
[marcus@manjaro joplin-docker]$ node-gyp -v

I use nvm to manage my multiple node versions.

Longer response for anyone who stumbles across this and is curious about what’s happening here:

Technically, it is in BUILD.md, but I scanned right over it the first time I built joplin as well. It explicitly says 10 (8 until very recently).

From what I understand, it’s really not super related to node-gyp, but is more likely related to the fact that sqlite3 cannot successfully compile against the version of v8 included in Node 12 13. This is a not super uncommon problem with packages with C dependencies and Node. At my last job, we would tell jokes about how often node-sass decided it needed to be rebuilt.

Damn you’re right! I completely glossed over that part of the BUILD.md. It works flawlessly with Node 10! Thanks for the background information.
Just out of curiosity, is there a reason why Node 10 is used for developing Joplin? I guess what most people will have installed by their distros will be Node 12 as that’s the current LTS. The only thing that seems to break for Node 12 / 13 is the sqlite package, as the AUR PKGBUILD indicates (Arch even ships Node 13 as the distro default Node)

No idea. That’s a @laurent question.

If I had to guess, it’s because that’s what he had around. Node 12 only became LTS a couple months ago. Aside from the fact that Arch likes to install them I generally avoid odd numbered Node versions.

Then again, the only time I really care about the Node version is at my day job so maybe the advice against them doesn’t apply to open source/desktop app development?