[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

  1. Update
  2. 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

View original on GitHub ↗

62 Comments

10-X-eng · 1 year ago

Just came here to write the same thing. Give this a whirl

npm install better-sqlite3

benny-yamagata · 1 year ago

FIx isnt working :( ran the command and same issue

AnthonyRonning · 1 year ago

Should be: npm -g install better-sqlite3 which works but I wouldn't expect to have to install an external dependency.

josh-gree · 1 year ago

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
imsahsol · 1 year ago

Yup, just updated and am experiencing this as well!

10-X-eng · 1 year ago
FIx isnt working :( ran the command and same issue

Strange. worked fine for me. hence why i posted it.

markpollack · 1 year ago

I had to upgrade to latest lts of node.

Node.js v22.15.0
$ npm install -g better-sqlite3

now all is good.

bcherny collaborator · 1 year ago

Sorry about that! Pushed a bad release.

We just unpublished 0.2.83. Please manually downgrade to fix:

npm install -g @anthropic-ai/claude-code@0.2.81
josh-gree · 1 year ago

@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?

bcherny collaborator · 1 year ago

Yes, you'll need to re-run /migrate-installer after, if you ran it previously. Sorry about that!

AnthonyRonning · 1 year ago

After downgrading and uninstalling better-sqlite3 (for those above that installed it), I can confirm it works again.

npm uninstall -g better-sqlite3
cahaseler · 1 year ago

honestly its reassuring when even the big guys accidentally push crap to prod. makes me feel better.

Zoomelectrico · 1 year ago
Should be: npm -g install better-sqlite3 which works but I wouldn't expect to have to install an external dependency.

This work on MacOS 15.3.2

cahaseler · 1 year ago

it worked, but it then automatically installed the bad update again and broke as soon as I restarted the tool.

andrewdavid48 · 1 year ago

We shouldn't need to install 'better-sqlite3' globally for claude to work. That should be a dependency the project is responsible to install.

cahaseler · 1 year ago
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.

andrewdavid48 · 1 year ago
> 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/claude-code@0.2.81

bcherny collaborator · 1 year ago
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?

msmygit · 1 year ago

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

msmygit · 1 year ago

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.

jamesheinlein · 1 year ago

would it be better to ship a "new version" with the rollback mitigation so that various tools/caches etc aren't confused?

aidevws · 1 year ago

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......

wolffiex collaborator · 1 year ago

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.

aidevws · 1 year ago
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.

meawoppl · 1 year ago
npm -g install better-sqlite3

Workaround works for me. I suspect was left out of the bundle somehow by accident.

AshwinSundar · 1 year ago
Sorry about that! Pushed a bad release. We just unpublished 0.2.83. Please manually downgrade to fix: `` npm install -g @anthropic-ai/claude-code@0.2.81 ``

This works @bcherny @wolffiex ; however claude automatically downloads the latest version and updates to the broken version after you close and restart the program. It looks like 0.2.83 is still available on npm as of this post -> https://www.npmjs.com/package/@anthropic-ai/claude-code

lieut-data · 1 year ago

If you want to prevent auto-upgrade until this gets sorted:

claude config set -g autoUpdaterStatus disabled

Just be sure to re-enable later to keep the fun going!

bcherny collaborator · 1 year ago

Just pointed the latest tag at v0.2.81 to work around NPM caching issues, so npm i -g @anthropic-ai/claude-code should install v0.2.81, not v0.2.83. Can someone confirm this fixes the issue for them?

lieut-data · 1 year ago

So far so good, @bcherny (and I re-enabled automatic updates). Thanks for the quick turnaround!

AshwinSundar · 1 year ago

@bcherny Was able to confirm the fix. I no longer receive a prompt to update to 0.2.83.

> npm install -g @anthropic-ai/claude-code@latest
changed 3 packages in 326ms
> claude --version
0.2.81 (Claude Code)

Thanks for the quick response!

igorkofman collaborator · 1 year ago

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 update to pick it up.

wolffiex collaborator · 1 year ago

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.

benny-yamagata · 1 year ago

Does this also solve the DB storage not supported error?

bcherny collaborator · 1 year ago

@benny-yamagata which issue is that? Feel free to open a new issue if you have a repro.

cliffordh · 1 year ago

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

Goldziher · 1 year ago

same, not working

igorkofman collaborator · 1 year ago

Could you try deleting ~/.claude/local

Honsal · 1 year ago

I had previously installed Claude Code locally, and even without downgrading, I ran npm i better-sqlite3 inside 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 ~/.claude folder, reinstalled Claude via npm, ran it using npm 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 .claude folder again, installed version 0.2.81, and tried to disable autoUpdaterStatus. 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/local and ran npm i @anthropic-ai/claude-code@0.2.81 to manually downgrade the local Claude package. After verifying with claude --version that it displayed 0.2.81 correctly, I tested it and confirmed that everything was working properly again.

------

The comment above is translated by AI.

cliffordh · 1 year ago
Could you try deleting ~/.claude/local

that ends up giving me a new problem

zsh: no such file or directory: /Users/xyz/.claude/local/claude

wolffiex collaborator · 1 year ago

@cliffordh can you try unalias claude and then npm install -g @anthropic-ai/claude-code ?

cliffordh · 1 year ago
@cliffordh can you try unalias claude and then npm install -g @anthropic-ai/claude-code ?

unalias was the key. Thanks.

slayton · 1 year ago

I'm seeing this again this today:

npm install -g @anthropic-ai/claude-code
npm ERR! code 1
npm ERR! path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild --release
npm ERR! TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR!   ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR!   TOUCH Release/obj.target/deps/locate_sqlite3.stamp
npm ERR!   CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
npm ERR!   LIBTOOL-STATIC Release/sqlite3.a
npm ERR!   CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
npm ERR! rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR! prebuild-install warn install No prebuilt binaries found (target=21.5.0 runtime=node arch=arm64 libc= platform=darwin)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@21.5.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.11.6 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/stuartlayton/Library/Caches/node-gyp/21.5.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/stuartlayton/Library/Caches/node-gyp/21.5.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/stuartlayton/Library/Caches/node-gyp/21.5.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/better_sqlite3.cpp:4:
npm ERR! ./src/better_sqlite3.lzz:2:10: fatal error: 'climits' file not found
npm ERR!     2 | #include <climits>
npm ERR!       |          ^~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Darwin 24.4.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/21.5.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v21.5.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /Users/stuartlayton/.npm/_logs/2025-04-26T12_52_58_941Z-debug-0.log

Happens if I pin the version as well with:

npm install -g @anthropic-ai/claude-code@0.2.84
wolffiex collaborator · 1 year ago

@slayton can you confirm your claude --version?

slayton · 1 year ago
claude --version
0.2.81 (Claude Code)
wolffiex collaborator · 1 year ago

ok that's interesting, this was actually an older version before we had the trouble yesterday. mind doing claude update and seeing what happens?

slayton · 1 year ago
 claude update
Current version: 0.2.81
Checking for updates...
New version available: 0.2.86 (current: 0.2.81)
Installing update...
Using global installation update method...
Error: Failed to install update
Or consider migrating to a local installation with:
  /migrate-installer
wolffiex collaborator · 1 year ago

can you do claude migrate-installer and then claude update ?

slayton · 1 year ago
claude migrate-installer

✗ Installation failed

Install of @anthropic-ai/claude-code failed
wolffiex collaborator · 1 year ago

oh man, sorry that you are stuck. does this command work for you?
npx @anthropic-ai/claude-code@latest

slayton · 1 year ago

Ok I ran

npx  @anthropic-ai/claude-code@latest
Need to install the following packages:
@anthropic-ai/claude-code@0.2.86
Ok to proceed? (y) y

then checked my version with:

claude --version
0.2.81 (Claude Code)
wolffiex collaborator · 1 year ago

ok right, that's good. I just wanted to be safe that at least that part is working. I think that if you do

npm install -g @anthropic-ai/claude-code@latest

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!

slayton · 1 year ago
npm install -g @anthropic-ai/claude-code@latest
npm ERR! code 1
npm ERR! path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild --release
npm ERR! TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR!   ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR!   TOUCH Release/obj.target/deps/locate_sqlite3.stamp
npm ERR!   CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
npm ERR!   LIBTOOL-STATIC Release/sqlite3.a
npm ERR!   CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
npm ERR! rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR! prebuild-install warn install No prebuilt binaries found (target=21.5.0 runtime=node arch=arm64 libc= platform=darwin)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@21.5.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.11.6 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/stuartlayton/Library/Caches/node-gyp/21.5.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/stuartlayton/Library/Caches/node-gyp/21.5.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/stuartlayton/Library/Caches/node-gyp/21.5.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/better_sqlite3.cpp:4:
npm ERR! ./src/better_sqlite3.lzz:2:10: fatal error: 'climits' file not found
npm ERR!     2 | #include <climits>
npm ERR!       |          ^~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Darwin 24.4.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/21.5.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v21.5.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /Users/stuartlayton/.npm/_logs/2025-04-26T16_57_14_802Z-debug-0.log
Saran33 · 1 year ago
`` npm install -g @anthropic-ai/claude-code@latest npm ERR! code 1 npm ERR! path /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3 npm ERR! command failed npm ERR! command sh -c prebuild-install || node-gyp rebuild --release npm ERR! TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate npm ERR! ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate npm ERR! TOUCH Release/obj.target/deps/locate_sqlite3.stamp npm ERR! CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o npm ERR! LIBTOOL-STATIC Release/sqlite3.a npm ERR! CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o npm ERR! rm ba23eeee118cd63e16015df367567cb043fed872.intermediate npm ERR! prebuild-install warn install No prebuilt binaries found (target=21.5.0 runtime=node arch=arm64 libc= platform=darwin) npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@10.0.1 npm ERR! gyp info using node@21.5.0 | darwin | arm64 npm ERR! gyp info find Python using Python version 3.11.6 found at "/opt/homebrew/opt/python@3.11/bin/python3.11" npm ERR! gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/Users/stuartlayton/Library/Caches/node-gyp/21.5.0/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/stuartlayton/Library/Caches/node-gyp/21.5.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/stuartlayton/Library/Caches/node-gyp/21.5.0/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! In file included from ../src/better_sqlite3.cpp:4: npm ERR! ./src/better_sqlite3.lzz:2:10: fatal error: 'climits' file not found npm ERR! 2 | #include <climits> npm ERR! | ^~~~~~~~~ npm ERR! 1 error generated. npm ERR! make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: make failed with exit code: 2 npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23) npm ERR! gyp ERR! System Darwin 24.4.0 npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/21.5.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release" npm ERR! gyp ERR! cwd /opt/homebrew/lib/node_modules/@anthropic-ai/claude-code/node_modules/better-sqlite3 npm ERR! gyp ERR! node -v v21.5.0 npm ERR! gyp ERR! node-gyp -v v10.0.1 npm ERR! gyp ERR! not ok npm ERR! A complete log of this run can be found in: /Users/stuartlayton/.npm/_logs/2025-04-26T16_57_14_802Z-debug-0.log ``

Upgrading node to 22 resolved it for me

wolffiex collaborator · 1 year ago

@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?

echo "=== Node/npm versions ==="
  node --version
  npm --version
  echo "=== Xcode CLT check ==="
  xcode-select -p 2>/dev/null || echo "No Xcode CLT path"
  ls -la /Library/Developer/CommandLineTools/usr/include/c++/v1/climits 2>/dev/null
  || echo "No climits header found"
  echo "=== Node-gyp environment ==="
  npm config get node-gyp
  which node-gyp
  node-gyp --version 2>/dev/null || echo "No standalone node-gyp"
  echo "=== Build flags ==="
  echo "CXXFLAGS: $CXXFLAGS"

_after_ you do that, you can also try npm install -g better-sqlite3
not suggesting this as a fix, but it may be a workaround for now

slayton · 1 year ago

results:

echo "=== Node/npm versions ==="
  node --version
  npm --version
  echo "=== Xcode CLT check ==="
  xcode-select -p 2>/dev/null || echo "No Xcode CLT path"
  ls -la /Library/Developer/CommandLineTools/usr/include/c++/v1/climits 2>/dev/null || echo "No climits header found"
  echo "=== Node-gyp environment ==="
  npm config get node-gyp
  which node-gyp
  node-gyp --version 2>/dev/null || echo "No standalone node-gyp"
  echo "=== Build flags ==="
  echo "CXXFLAGS: $CXXFLAGS"
=== Node/npm versions ===
v21.5.0
10.2.4
=== Xcode CLT check ===
/Library/Developer/CommandLineTools
No climits header found
=== Node-gyp environment ===
undefined
node-gyp not found
No standalone node-gyp
=== Build flags ===
CXXFLAGS:
slayton · 1 year ago

Trying to install better-sqlite3 yields the same error:

npm install -g better-sqlite3
npm ERR! code 1
npm ERR! path /opt/homebrew/lib/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild --release
npm ERR! TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR!   ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR!   TOUCH Release/obj.target/deps/locate_sqlite3.stamp
npm ERR!   CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
npm ERR!   LIBTOOL-STATIC Release/sqlite3.a
npm ERR!   CXX(target) Release/obj.target/better_sqlite3/src/better_sqlite3.o
npm ERR! rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
npm ERR! prebuild-install warn install No prebuilt binaries found (target=21.5.0 runtime=node arch=arm64 libc= platform=darwin)
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@21.5.0 | darwin | arm64
npm ERR! gyp info find Python using Python version 3.11.6 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/better-sqlite3/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/Users/stuartlayton/Library/Caches/node-gyp/21.5.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/Users/stuartlayton/Library/Caches/node-gyp/21.5.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/stuartlayton/Library/Caches/node-gyp/21.5.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/opt/homebrew/lib/node_modules/better-sqlite3',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/better_sqlite3.cpp:4:
npm ERR! ./src/better_sqlite3.lzz:2:10: fatal error: 'climits' file not found
npm ERR!     2 | #include <climits>
npm ERR!       |          ^~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/better_sqlite3/src/better_sqlite3.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Darwin 24.4.0
npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/21.5.0/bin/node" "/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
npm ERR! gyp ERR! cwd /opt/homebrew/lib/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v21.5.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: /Users/stuartlayton/.npm/_logs/2025-04-28T13_30_55_131Z-debug-0.log
slayton · 1 year ago

I updated node to v23.11.0 and then things installed fine.

npm install -g @anthropic-ai/claude-code@latest

added 38 packages, and changed 3 packages in 5s

11 packages are looking for funding
  run `npm fund` for details
claude -v
0.2.86 (Claude Code)
wolffiex collaborator · 1 year ago

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

sudo rm -rf /Library/Developer/CommandLineTools
  xcode-select --install
evanorti · 1 year ago

@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:

  ERROR The module '/Users/evan/.npm-global/lib/node_modules/@anthropic-ai/clau
       de-code/node_modules/better-sqlite3/build/Release/better_sqlite3.node'
       was compiled against a different Node.js version using
       NODE_MODULE_VERSION 127. This version of Node.js requires
       NODE_MODULE_VERSION 115. Please try re-compiling or re-installing
       the module (for instance, using `npm rebuild` or `npm install`).

 - was compiled against a different Node.js version using
 - NODE_MODULE_VERSION 127. This version of Node.js requires
 - NODE_MODULE_VERSION 115. Please try re-compiling or re-installing
 - the module (for instance, using `npm rebuild` or `npm install`).
 - Module._extensions..node (node:internal/modules/cjs/loader:1651:18)
 - Module.load (node:internal/modules/cjs/loader:1275:32)
 - Module._load (node:internal/modules/cjs/loader:1096:12)
 - Module.require (node:internal/modules/cjs/loader:1298:19)
 - require (node:internal/modules/helpers:182:18)
 - bindings (node_modules/bindings/bindings.js:112:48)
 - Database (node_modules/better-sqlite3/lib/database.js:48:64)
 -  (cli.js:532:25217)
 - D (cli.js:505:12907)
 - Ah0 (cli.js:532:26283)
 - ```

I've checked many times; I'm using NODE_MODULE_VERSION 115

Can anyone help?
wolffiex collaborator · 1 year ago

@evanorti sorry for the trouble. the very latest version, 0.2.100 should be avoid the crash. can you confirm --version?

evanorti · 1 year ago

@wolffiex It was not updating to 2.100. I cleared everything and now it is installing the latest version. Things are working again. Thanks!

github-actions[bot] · 11 months ago

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.