Cannot run packages/app-desktop due an issue with node_sqlite3.node

I am attempting to build the desktop app with a view to submitting a pull request.

I am following the BUILD.md guide.

When I run cd packages/app-desktop then yarn start Electron opens but there is an error in the console:

Uncaught Error: Cannot find module '/home/jp/joplin/packages/app-desktop/node_modules/sqlite3/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node'
Require stack:
- /home/jp/joplin/packages/app-desktop/node_modules/sqlite3/lib/sqlite3-binding.js
- /home/jp/joplin/packages/app-desktop/node_modules/sqlite3/lib/sqlite3.js
- /home/jp/joplin/packages/app-desktop/index.html
    at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at i._resolveFilename (node:electron/js2c/renderer_init:33:1095)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at i._load (node:electron/js2c/renderer_init:33:356)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/jp/joplin/packages/app-desktop/node_modules/sqlite3/lib/sqlite3-binding.js:4:17)
    at Object.<anonymous> (/home/jp/joplin/packages/app-desktop/node_modules/sqlite3/lib/sqlite3-binding.js:7:3)
    at Module._compile (node:internal/modules/cjs/loader:1118:14)

This is on an M1 Mac.

Instead of napi-v6-darwin-unknown-arm64 I have an napi-v6-darwin-unknown-x64 directory.

So it seems that Joplin is using the correct architecture, arm64, but yarn has installed the wrong one.

I am unfamiliar with how yarn chooses which architecture to install.

Has anyone successfully built Joplin on an M1 Mac?

Thanks for contributing to a great app!

There are flags to build for M1 using npm, and there might be some for yarn too. It's not really specific to Joplin so you might have more luck on SO or the sqlite repo

You might find something useful here - ARM build for mac os M1 processor · Issue #6052 · laurent22/joplin · GitHub