Commit f043736
authored
Added Claude Code Bash hook to align Node version with .nvmrc (#28831)
Adds a `PreToolUse[Bash]` hook so commands inherit the Node version
pinned in `.nvmrc`.
Works around
[anthropics/claude-code#54135](anthropics/claude-code#54135):
the Claude Code Desktop launcher enumerates every
`~/.nvm/versions/node/v*/bin` directory into PATH in lexical order, so
the lowest-installed Node wins regardless of `nvm alias default` or
`.nvmrc`. In practice this means agents land on Node 16 (or whatever's
lexically first), which crashes corepack at the husky pre-commit hook.
The hook sources nvm and runs `nvm use` before each Bash command. Silent
no-op on machines without nvm.1 parent 1ed2aac commit f043736
1 file changed
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments