Back to: Technology Guides

How to make node sqlite3 work with Apple Silicon M1

To make node sqlite3 work on an Apple Silicon M1 Mac today, upgrade sqlite3 to version 5.1.1 or later and run an arm64 build of Node.js. Since sqlite3 v5.1.1 (September 2022), the package ships a prebuilt darwin-arm64 binary, so a plain npm install sqlite3 works with no build flags.

The build-from-source workaround this post first described is only needed if you are stuck on a release older than 5.1.1. It is still below, for those projects.

  • sqlite3 5.1.1 and later: prebuilt Apple Silicon (darwin-arm64) binaries. No workaround needed.

  • Latest release, as of November 2026: sqlite3 6.0.1 (March 2026), which needs Node.js 20.17.0 or later.

  • Most common cause today: an Intel (x64) build of Node running under Rosetta, so npm fetches the Intel binary.

  • Node.js LTS, as of November 2026: Node 26 is the active LTS release.

Is the node sqlite3 Apple Silicon fix still needed?

No, not with current releases. The sqlite3 maintainers added Darwin ARM64 binaries in v5.1.1, released on 15 September 2022, and every release since includes them. The project README lists darwin-arm64 among the prebuilt targets, next to darwin-x64, Linux and Windows (node-sqlite3 on GitHub).

Two other changes matter if you are upgrading an old project:

  • v5.1.7 (January 2024) replaced @mapbox/node-pre-gyp with prebuild-install for downloading binaries. The old --target_arch and --fallback-to-build flags belong to node-pre-gyp.

  • v6.0.0 (March 2026) marked the repository as unmaintained, and v6.0.1 fixed the Alpine Linux binaries. Version 6 requires Node.js 20.17.0 or later; on older Node versions, stay on 5.1.7.

How to fix node sqlite3 on an M1 Mac today

Check which architecture Node runs as, install an arm64 Node if needed, then reinstall sqlite3. On Apple Silicon, process.arch should print arm64.

  1. Run node -p process.arch. If it prints x64, your Node is an Intel build running under Rosetta.

  2. If so, install the macOS arm64 build of the current LTS release from nodejs.org (or reinstall it with your version manager from an arm64 terminal).

  3. Delete node_modules and reinstall, so npm downloads the darwin-arm64 binary.

  4. Load the module to confirm it works.

node -p process.arch rm -rf node_modules npm install sqlite3@latest node -e "require('sqlite3'); console.log('sqlite3 loaded')"

As of November 2026, Node.js 26 (Lithium) is the active LTS release, at 26.13.1. Node 24 and Node 22 are in maintenance until April 2028 and April 2027, and Node 20 has reached end of life, per the Node.js release list.

When we set up Node projects on Apple Silicon Macs at msmtech, node -p process.arch is the first thing we run. A terminal opened with Rosetta, an Intel copy of Homebrew or an old version manager install can each give you an x64 Node without any warning.

Why node sqlite3 failed on Apple Silicon

sqlite3 is a native add-on: alongside the JavaScript, it loads a compiled binary that must match the architecture Node runs as. node-pre-gyp, which older releases used, picks the binary by Node’s process.arch (node-pre-gyp docs).

Before v5.1.1 there was no prebuilt darwin-arm64 binary, so npm had to compile one, and the build failed on Macs without compiler tools. A second, sneakier failure came from mixed architectures:

  • npm installed sqlite3 under an x64 Node, so it fetched the Intel binary, in a folder such as napi-v6-darwin-unknown-x64.

  • The app then ran under an arm64 Node, which looked for napi-v6-darwin-unknown-arm64 and threw a "Cannot find module" error.

  • If the arm64 Node did load the Intel file, macOS refused it with an incompatible architecture error.

The fix in both cases is the same: one architecture for install and run, and a sqlite3 version with a binary for it.

Workaround for sqlite3 versions older than 5.1.1

If a dependency pins sqlite3 below 5.1.1, build the binding from source for arm64. The flags below are node-pre-gyp options, which those releases used: --build-from-source skips the download, --target_arch overrides the detected architecture, and --fallback-to-build compiles when no binary exists.

  1. Install Apple’s compiler tools with xcode-select --install. node-gyp also needs a supported version of Python.

  2. Uninstall sqlite3.

  3. Reinstall it, built from source for arm64.

xcode-select --install npm uninstall sqlite3 npm install sqlite3 --build-from-source --target_arch=arm64 --fallback-to-build

On sqlite3 5.1.7 and later, a source build is just npm install sqlite3 --build-from-source, per the README. You should rarely need it on a Mac.

Should you still use sqlite3 in 2026?

For existing code, yes: upgrade to the latest release and it works on Apple Silicon. For new projects, weigh two facts. The node-sqlite3 repository says it is unmaintained and will not act on issues or pull requests. Node.js now has a built-in node:sqlite module, added in v22.5.0 and marked release candidate (stability 1.2) since v25.7.0.

Our rule of thumb: if you target Node 24 or 26 and only need SQLite’s core features, try node:sqlite first, since there is no native add-on to match to your Mac. If you rely on sqlite3’s callback API or need Node 20, stay on sqlite3 and pin a current version.

Frequently asked questions

Does node sqlite3 work on M2, M3 and M4 Macs?

Yes. Every Apple silicon chip, from M1 onward, runs the same arm64 architecture, so the darwin-arm64 binary in sqlite3 5.1.1 and later covers all of them.

How do I know if Node is running under Rosetta?

Run node -p process.arch. On an Apple silicon Mac, arm64 means a native build and x64 means an Intel build translated by Rosetta. Reinstall Node from an arm64 terminal to fix it.

Will Rosetta keep working for an Intel build of Node?

Not for long. Apple says Rosetta is available up to macOS 27, and that from macOS 28 it will be limited to certain older games (Apple’s Rosetta page). Move Node and your native modules to arm64 now.

Do I need Xcode to install sqlite3 on a Mac?

No, not with a prebuilt binary, which current releases have for Apple Silicon. You only need the Xcode Command Line Tools when npm builds sqlite3 from source, such as on a release older than 5.1.1.

Need help with a Node.js application? Talk to msmtech, or see how we handle custom software and enterprise web apps.

No off-the-shelf solution? We'll build it.