Earlier this week I installed a globally distributed Node.js tool — n8n, via npm install -g — on Windows. It crashed on startup with this:
Initial database connection attempt 1 failed: SQLite package has not been found installed. Try to install it: npm install sqlite3 --save. Retrying in 1000ms Five retries. Then it gave up for good:
Error: There was an error initializing DB DriverPackageNotInstalledError: SQLite package has not been found installed. Try to install it: npm install sqlite3 --save at SqliteLibrary.loadLibrary (...\@n8n\typeorm\dist\driver\sqlite-pooled\SqliteLibrary.js:30:19) Now, here's the part that still annoys me: sqlite3 was installed. Twice, in fact. Once globally, once nested inside the tool itself. The error message was lying — and the lie cost me a full hour, because I kept believing it.
This post is that debugging session, plus the method I walked away with. The method generalizes: it works for any native module that "cannot be found" when you know perfectly well it exists.
Prerequisites
- Windows, Node v22, npm 10
- A globally installed CLI tool that vendors
sqlite3as a nested dependency - A terminal, so you can fire off
node -eone-liners
Step 1 — Symptom: verify the package before touching anything
The error tells you to run npm install sqlite3 --save. Don't. Not yet. First find out what actually exists:
npm ls -g sqlite3 # └── sqlite3@6.0.1 Installed. So why does the tool insist otherwise?
The answer sits in the throwing code. I opened SqliteLibrary.js and found this:
loadLibrary() { try { const sqlite = this.options.driver || require('sqlite3'); this.sqlite = sqlite.verbose(); } catch (e) { throw new DriverPackageNotInstalledError('SQLite', 'sqlite3'); } } That catch swallows everything. Any failure inside require('sqlite3') — including "the native binary that lives inside the package is missing" — gets relabeled as "the package is not installed." A loading failure and an installation failure produce the exact same misleading sentence.
Lesson 1: when a wrapper catches
require()and translates it into "package not installed," the package is rarely the problem. The loader is.
Step 2 — Hypothesis: two ways this can be true
Suppose the package exists but require fails anyway. Only two explanations are possible:
- Resolution picks a different copy than the one that works — nested
node_modulesshadowing. - The resolved copy exists, but its native binary doesn't — a
.nodefile that never made it down at install time.
One command distinguishes them. Ask Node what it would load, from the perspective of the code that's failing:
node -e "console.log(require.resolve('sqlite3', { paths: ['C:/path/to/the/tool/node_modules/@n8n/typeorm'] }))" Out comes:
C:\...\node_modules\n8n\node_modules\sqlite3\lib\sqlite3.js There it is. The tool ships its own nested sqlite3 (5.1.7) inside its node_modules, and Node's resolution walks the ancestor chain starting from the failing file — so it hits the nested copy before my global 6.0.1. The global copy I confirmed in Step 1? Never even a candidate.
Hypothesis 1, dead. Everything now points at hypothesis 2.
Step 3 — Verify: load each copy directly
Load both copies in isolation and compare:
# global copy — loads fine node -e "require('C:/.../node_modules/sqlite3'); console.log('OK')" # nested copy — the real failure, finally speaking for itself node -e "require('C:/.../node_modules/n8n/node_modules/sqlite3')" The nested copy's error is nothing like what the tool reported:
Error: Could not locate the bindings file. Tried: → ...\sqlite3\build\node_sqlite3.node → ...\sqlite3\build\Debug\node_sqlite3.node → ...\sqlite3\build\Release\node_sqlite3.node → ...\sqlite3\out\Release\node_sqlite3.node → ...\sqlite3\lib\binding\node-v127-win32-x64\node_sqlite3.node ... No build/Release/node_sqlite3.node anywhere. The nested package shipped without its native binary.
Why? Because sqlite3's install script downloads a prebuilt binary from GitHub Releases at install time — and I was on a corporate network where that download failed silently. npm install -g reported success. The missing binary only surfaced hours later, at runtime, wearing a disguise.
Lesson 2: a silent network failure during install becomes a misleading error at runtime. The farther apart those two moments are, the harder the debugging gets.
Step 4 — Fix: fetch the prebuilt binary manually
I tried three shortcuts before the real fix. Keeping them in — each one is a trap worth knowing.
Trap 1 — prebuild-install doesn't fix it:
cd .../n8n/node_modules/sqlite3 npm_config_proxy=http://127.0.0.1:7890 npx --yes prebuild-install # warn install Client network socket disconnected before secure TLS # connection was established The binary fetcher needs GitHub access itself, and its proxy configuration refused to cooperate. Same wall, different tool.
Trap 2 — guessing the release URL 404s:
The prebuilt binaries live on the project's GitHub Releases. I guessed the asset name using the old Node ABI convention:
https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/node-v127-win32-x64.tar.gz What that downloads is a 9-byte file containing Not Found. Modern sqlite3 builds are N-API builds, so the assets are named napi-vX, not node-vXXX:
-
(my guess — doesn't exist)node-v127-win32-x64.tar.gz -
sqlite3-v5.1.7-napi-v6-win32-x64.tar.gz(real asset)
N-API binaries are ABI-stable across Node versions — which is exactly why the Node version disappeared from the filename. Guess the old convention and you'll 404 every time.
Trap 3 — the GitHub API may be rate-limited:
The obvious next move is listing release assets through the API:
curl https://api.github.com/repos/TryGhost/node-sqlite3/releases/tags/v5.1.7 If your proxy exit IP is shared — and on any corporate proxy or VPN, it is — you can inherit some stranger's exhausted rate limit:
{"message":"API rate limit exceeded for 203.190.x.x. (But here's the good news: Authenticated requests get a higher rate limit...)"} The workaround that actually worked: scrape the release page's asset list, which carries no rate limit:
curl -sSL "https://github.com/TryGhost/node-sqlite3/releases/expanded_assets/v5.1.7" \ | grep -o 'href="[^"]*"' | grep -i "win32-x64" Real asset names, no API involved.
The fix itself (through a proxy that works):
cd .../n8n/node_modules/sqlite3 # the NESTED copy, not your global one curl -sSL -x http://127.0.0.1:7890 -o binding.tar.gz \ "https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v6-win32-x64.tar.gz" tar -xzf binding.tar.gz -C . One more trap hides in that last line. The tarball already contains build/Release/node_sqlite3.node — so if you extract with -C build/Release (which felt perfectly logical to me for about thirty seconds), you end up with build/Release/build/Release/... and the same "could not locate bindings" error. Extract to the package root.
Then verify — no need to launch the whole tool:
node -e "require('./lib/sqlite3.js'); console.log('fixed')" # fixed The next n8n start ran to completion.
Step 5 — Generalize: a checklist for lying "package not found" errors
Any time a native module — anything that loads a .node binary: sqlite3, bcrypt, canvas, sharp, node-pty... — claims it isn't installed:
- Don't reinstall. Check
npm ls -g <pkg>(or the lockfile) first. If it's there, the error is lying, and you're debugging a loader, not an installer. - Ask what resolution actually picks —
require.resolve(pkg, { paths: [dir-of-the-failing-code] }). Nested copies shadow your global/parent install; you need to know which copy is losing. - Load each candidate copy directly with
node -e "require(...)". The direct error ("Could not locate the bindings file") beats the wrapper's relabeled one. - If a native binary is missing, the install-time download failed silently. Fetch it manually from the project's GitHub Releases — remembering that assets are
napi-vX(N-API) today, not thenode-vXXXABI names older guides mention. - On restricted networks, the binary fetcher (
prebuild-install) may fail where a plaincurl -x proxysucceeds. Don't fight the tool. Use curl, place the file yourself. - Read the throwing code when an error smells wrong. Ten lines of
try/catchexplained the whole mystery at a glance.
Takeaways
- "Package not found" from a wrapper's
catchblock is a category of failure, not a diagnosis. - Node resolves modules along the ancestor chain from the requiring file — nested copies always shadow yours, and
npm install -g <pkg>will never fix a nested copy. - Silent install-time failures on restricted networks surface later as runtime lies. The gap between cause and symptom is what makes them hard.
- When the GitHub API rate-limits you behind a shared proxy IP, the
expanded_assetsHTML page is your friend.
The meta-lesson I'm keeping from this one: when an error tells you a package is missing, the package is rarely the problem — the loader is. Verify before you reinstall.
Companion snippets for this post: https://github.com/MrL5z2k0/when-errors-lie

