[BUG] Cannot find package 'better-sqlite3'
Just updated 5 minutes ago, doesn't launch anymore....
Environment
- Platform (select one):
- Anthropic API
- Claude CLI version: no clue, errors out
- Operating System: ubuntu 24.04 nix
- Terminal: tmux
Bug Description
claude
node:internal/modules/esm/resolve:854
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'better-sqlite3' imported from /home/tony/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js
at packageResolve (node:internal/modules/esm/resolve:854:9)
at moduleResolve (node:internal/modules/esm/resolve:927:18)
at defaultResolve (node:internal/modules/esm/resolve:1169:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
at link (node:internal/modules/esm/module_job:86:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v20.15.1
Steps to Reproduce
- Update
- Launch claude
Expected Behavior
It should work
Actual Behavior
It doesnt work
Official workaround (via @bcherny ):
npm install -g @anthropic-ai/[email protected]
Older, unofficial workarounds
Install globally (via @10-X-eng ):
npm -g install better-sqlite3
Or install locally if your claude is in ~/.claude/local` (via @josh-gree ):
cd ~/.claude/local
npm install better-sqlite3
Just came here to write the same thing. Give this a whirl
npm install better-sqlite3
FIx isnt working :( ran the command and same issue
Should be: npm -g install better-sqlite3 which works but I wouldn't expect to have to install an external dependency.
That doesn't work either - its installation isn't global anymore they changed this at some point - it installs in ~ /.claude/local now :-(
can fix by doing;
cd ~/.claude/local
npm install better-sqlite3
Yup, just updated and am experiencing this as well!
FIx isnt working :( ran the command and same issue
Strange. worked fine for me. hence why i posted it.
I had to upgrade to latest lts of node.
Node.js v22.15.0 $ npm install -g better-sqlite3
now all is good.
Sorry about that! Pushed a bad release.
We just unpublished 0.2.83. Please manually downgrade to fix:
npm install -g @anthropic-ai/[email protected]
@bcherny how does this work with the change in installation that was rolled out previously - wasn't that done to remove the global install?
There was a / command "fix install" or something right?
Yes, you'll need to re-run /migrate-installer after, if you ran it previously. Sorry about that!
After downgrading and uninstalling better-sqlite3 (for those above that installed it), I can confirm it works again.
npm uninstall -g better-sqlite3
honestly its reassuring when even the big guys accidentally push crap to prod. makes me feel better.
Should be:
npm -g install better-sqlite3which works but I wouldn't expect to have to install an external dependency.
This work on MacOS 15.3.2
it worked, but it then automatically installed the bad update again and broke as soon as I restarted the tool.
We shouldn't need to install 'better-sqlite3' globally for claude to work. That should be a dependency the project is responsible to install.
We shouldn't need to install 'better-sqlite3' globally for claude to work. That should be a dependency the project is responsible to install.
I think they agree, they accidentally broke it is all.
We shouldn't need to install 'better-sqlite3' globally for claude to work. That should be a dependency the project is responsible to install.
I think they agree, they accidentally broke it is all.
Agreed. I'm not throwing blame, just pointing out that npm i -g should not be the solution, even for a temporary fix.
If anything, it's safest to just run a previous version, e.g.: npx @anthropic-ai/[email protected]
it worked, but it then automatically installed the bad update again and broke as soon as I restarted the tool.
@cahaseler the new version is unpublished, so it might be an NPM cache or something. Try again?
I'm stuck with this same exact issue.
· Computing… (2460s · ⚒ 19.5k tokens · esc to interrupt)
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ > │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
⏵⏵ auto-accept edits on (shift+tab to toggle) ✓ Update installed · Restart to apply
and then boom, everything is broke!
% claude
node:internal/modules/package_json_reader:268
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'better-sqlite3' imported from /Users/user/.npm-global/lib/node_modules/@anthropic-ai/claude-code/cli.js
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:268:9)
at packageResolve (node:internal/modules/esm/resolve:768:81)
at moduleResolve (node:internal/modules/esm/resolve:854:18)
at defaultResolve (node:internal/modules/esm/resolve:984:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:685:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:634:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:617:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:273:38)
at ModuleJob._link (node:internal/modules/esm/module_job:135:49) {
code: 'ERR_MODULE_NOT_FOUND'
}
Node.js v22.14.0
FWIW, I'm on macOS 15.3.2 (24D81), node v22.14.0, npm at 10.9.2
fwiw, I also got below warnings in between and I deleted the prefix files too,
Your user’s .npmrc file (${HOME}/.npmrc)
has a `globalconfig` and/or a `prefix` setting, which are incompatible with nvm.
Run `nvm use --delete-prefix v22.14.0 --silent` to unset it.
no luck, nothing works. I tried to npm install -g @anthropic-ai/claude-code and still the same error.