[BUG] Cannot find package 'better-sqlite3'
Resolved 💬 62 comments Opened Apr 25, 2025 by AnthonyRonning Closed May 4, 2025
💡 Likely answer: A maintainer (bcherny, collaborator)
responded on this thread — see the highlighted reply below.
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/claude-code@0.2.81
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
62 Comments
Just came here to write the same thing. Give this a whirl
npm install better-sqlite3FIx isnt working :( ran the command and same issue
Should be:
npm -g install better-sqlite3which 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/localnow :-(can fix by doing;
Yup, just updated and am experiencing this as well!
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:
@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-installerafter, 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.
honestly its reassuring when even the big guys accidentally push crap to prod. makes me feel better.
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.
I think they agree, they accidentally broke it is all.
Agreed. I'm not throwing blame, just pointing out that
npm i -gshould 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/claude-code@0.2.81@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.
and then boom, everything is broke!
FWIW, I'm on macOS
15.3.2 (24D81), nodev22.14.0, npm at10.9.2fwiw, I also got below warnings in between and I deleted the prefix files too,
no luck, nothing works. I tried to
npm install -g @anthropic-ai/claude-codeand still the same error.would it be better to ship a "new version" with the rollback mitigation so that various tools/caches etc aren't confused?
Task(Find all relevant files in the project that might help understand the current …
logging setup and OpenTelemetry configuration. Look specifically for:…)
⎿ DB storage not supported
hhhmmm......
Sorry folks, I broke this. I obviously missed something regarding the way that better-sqlite3 native dependencies work. I will test this scenario carefully before we try again.
Don't worry, it happens, we are human and we tend to make mistakes.
Workaround works for me. I suspect was left out of the bundle somehow by accident.
This works @bcherny @wolffiex ; however
claudeautomatically downloads the latest version and updates to the broken version after you close and restart the program. It looks like0.2.83is still available onnpmas of this post -> https://www.npmjs.com/package/@anthropic-ai/claude-codeIf you want to prevent auto-upgrade until this gets sorted:
Just be sure to re-enable later to keep the fun going!
Just pointed the
latesttag at v0.2.81 to work around NPM caching issues, sonpm i -g @anthropic-ai/claude-codeshould install v0.2.81, not v0.2.83. Can someone confirm this fixes the issue for them?So far so good, @bcherny (and I re-enabled automatic updates). Thanks for the quick turnaround!
@bcherny Was able to confirm the fix. I no longer receive a prompt to update to 0.2.83.
Thanks for the quick response!
Thanks for you patience folks! We've just deployed a new version 0.2.84 which should resolve the issue. Would love a 👍 that it's working for everyone. You can
claude updateto pick it up.Sorry again for the breakage here. On the plus side, this is in support of an oft-requested feature that we will have in your hands soon.
Does this also solve the
DB storage not supportederror?@benny-yamagata which issue is that? Feel free to open a new issue if you have a repro.
Not working over here... did an uninstall, cache clean and reinstall... still getting an error:
└─❯ claude --version
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/xxx/.claude/local/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
same, not working
Could you try deleting ~/.claude/local
I had previously installed Claude Code locally, and even without downgrading, I ran
npm i better-sqlite3inside the local Claude installation folder and was able to use it without any issues for a while.However, starting a few minutes ago, a "DB storage not supported" error suddenly began occurring. To resolve this, I deleted the
~/.claudefolder, reinstalled Claude via npm, ran it usingnpm exec claude(due to path issues), and performed/migrate-installer, but the "DB storage not supported" error still persisted (using Claude version 0.2.84).While investigating, I came across a related issue report. I then deleted the
.claudefolder again, installed version 0.2.81, and tried to disableautoUpdaterStatus. However, since I couldn't modify that setting before a local installation was complete, I launched Claude and performed/migrate-installer.At that point, I noticed that due to automatic updates, Claude had been updated back to 0.2.84. So, without launching Claude again, I executed
claude config set -g autoUpdaterStatus disabled, then navigated to~/.claude/localand rannpm i @anthropic-ai/claude-code@0.2.81to manually downgrade the local Claude package. After verifying withclaude --versionthat it displayed 0.2.81 correctly, I tested it and confirmed that everything was working properly again.------
The comment above is translated by AI.
that ends up giving me a new problem
zsh: no such file or directory: /Users/xyz/.claude/local/claude
@cliffordh can you try
unalias claudeand thennpm install -g @anthropic-ai/claude-code?unalias was the key. Thanks.
I'm seeing this again this today:
Happens if I pin the version as well with:
@slayton can you confirm your
claude --version?ok that's interesting, this was actually an older version before we had the trouble yesterday. mind doing
claude updateand seeing what happens?can you do
claude migrate-installerand thenclaude update?oh man, sorry that you are stuck. does this command work for you?
npx @anthropic-ai/claude-code@latestOk I ran
then checked my version with:
ok right, that's good. I just wanted to be safe that at least that part is working. I think that if you do
you should be back in business. let me know if that doesn't work. we obviously have work to do to harden our installer so it can't get into bad states like this. thank you for your patience!
Upgrading node to 22 resolved it for me
@slayton thanks for your patience. it's really helpful to gather info about what isn't working. would you mind running this script and pasting the output?
_after_ you do that, you can also try
npm install -g better-sqlite3not suggesting this as a fix, but it may be a workaround for now
results:
Trying to install
better-sqlite3yields the same error:I updated node to
v23.11.0and then things installed fine.Ok thanks again @slayton
I think the issue here is with using an unsupported (non LTS) Node version
If you upgrade to Node 22, it should be fixed as Saran33 reports
Based on your diagnostic output, an alternative may be to reinstall the XCode helpers
@wolffiex I have tried all the solutions listed in this chat and nothing works. I have uninstalled claude code and deleted all files in .claude, used different node versions, reinstalled claude many times, rebuilt npm and sqlite, installed locally, but I still get this error every time:
@evanorti sorry for the trouble. the very latest version, 0.2.100 should be avoid the crash. can you confirm --version?
@wolffiex It was not updating to 2.100. I cleared everything and now it is installing the latest version. Things are working again. Thanks!
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.