Skip to content

Commit 047c652

Browse files
committed
Pin Node version in .nvmrc instead of hardcoding it in the hook
Add a .nvmrc set to lts/krypton (matching CI's setup-node) and have the SessionStart hook run `nvm install`/`nvm use` without a version argument so the pinned version is the single source of truth. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NvxEaPhyEq2HCZ6XFjEAde
1 parent 09c612c commit 047c652

4 files changed

Lines changed: 18 additions & 14 deletions

File tree

.claude/hooks/session-start.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# SessionStart hook: bootstraps the repo so a fresh Claude Code worker can build,
44
# lint and test the Node.js tooling packages out of the box.
55
#
6-
# It ensures Node.js 24 (required by "devEngines" in package.json), installs the
7-
# npm workspace dependencies and builds the TypeScript project references.
6+
# It ensures the Node.js version pinned in .nvmrc (which matches CI), installs
7+
# the npm workspace dependencies and builds the TypeScript project references.
88
#
99
# Native iOS/Android artifacts are intentionally NOT built here: they require the
1010
# Android NDK / Apple toolchains which are not present on a generic Linux worker.
@@ -19,9 +19,10 @@ fi
1919

2020
cd "${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel)}"
2121

22-
# --- Ensure Node.js 24 via nvm -----------------------------------------------
23-
# package.json's devEngines pins Node ^24 (and npm ^11); npm refuses to install
24-
# with an older runtime. nvm ships on the remote workers, so use it to select 24.
22+
# --- Ensure the Node.js version from .nvmrc via nvm ---------------------------
23+
# .nvmrc pins the Node version (matching CI). package.json's devEngines requires
24+
# Node ^24 / npm ^11, and npm refuses to install with an older runtime. nvm ships
25+
# on the remote workers, so use it to install and select the pinned version.
2526
NVM_DIR="${NVM_DIR:-/opt/nvm}"
2627
if [ ! -s "$NVM_DIR/nvm.sh" ] && [ -s "$HOME/.nvm/nvm.sh" ]; then
2728
NVM_DIR="$HOME/.nvm"
@@ -33,14 +34,15 @@ if [ -s "$NVM_DIR/nvm.sh" ]; then
3334
set +u
3435
# shellcheck disable=SC1091
3536
. "$NVM_DIR/nvm.sh"
36-
nvm install 24 >/dev/null
37-
nvm use 24 >/dev/null
37+
# No version argument: nvm reads .nvmrc from the current directory.
38+
nvm install >/dev/null
39+
nvm use >/dev/null
40+
NODE_BIN="$(dirname "$(nvm which current)")"
3841
set -u
3942

40-
NODE_BIN="$(dirname "$(nvm which 24)")"
4143
export PATH="$NODE_BIN:$PATH"
4244

43-
# Persist the Node 24 toolchain on PATH for the rest of the session.
45+
# Persist the resolved Node toolchain on PATH for the rest of the session.
4446
if [ -n "${CLAUDE_ENV_FILE:-}" ]; then
4547
echo "export PATH=\"$NODE_BIN:\$PATH\"" >> "$CLAUDE_ENV_FILE"
4648
fi

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/krypton

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ See the [README.md](README.md#packages) for detailed descriptions of each packag
2525

2626
## Environment & Bootstrap
2727

28-
- **Node.js 24 is required**`package.json`'s `devEngines` pins Node `^24` (and npm `^11`), and npm refuses to install with an older runtime.
28+
- **Node.js 24 is required**pinned in `.nvmrc` as `lts/krypton` (matching CI); `package.json`'s `devEngines` requires Node `^24` and npm `^11`, and npm refuses to install with an older runtime. With nvm: `nvm install && nvm use`.
2929
- Standard setup for the Node.js tooling packages:
3030

3131
```bash
3232
npm install # Install workspace dependencies
3333
npm run build # Incremental TypeScript build (tsc --build)
3434
```
3535

36-
- On Claude Code on the web, `.claude/hooks/session-start.sh` performs the above automatically (selecting Node 24 via nvm) at session start.
36+
- On Claude Code on the web, `.claude/hooks/session-start.sh` performs the above automatically (selecting the `.nvmrc` version via nvm) at session start.
3737
- **Native (iOS/Android) builds are not part of the default bootstrap.** `npm run bootstrap` and the native `bootstrap` scripts compile artifacts that require the Android NDK / Apple toolchains, which are absent on a generic Linux worker. Focus on the Node.js tooling packages; pass an explicit target (e.g. `npx ferric --apple`) only when the corresponding SDK is installed.
3838

3939
## Critical Build Dependencies

CLAUDE.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ duplicating content here:
1212
## Claude Code on the web
1313

1414
A `SessionStart` hook (`.claude/hooks/session-start.sh`) bootstraps remote
15-
workers automatically: it selects Node.js 24 via `nvm` (required by
16-
`package.json`'s `devEngines`), then runs `npm install` and `npm run build`, so a
17-
fresh session is ready to build, lint, and test the Node.js tooling packages.
15+
workers automatically: it selects the Node.js version pinned in `.nvmrc` via
16+
`nvm` (Node 24, as required by `package.json`'s `devEngines`), then runs
17+
`npm install` and `npm run build`, so a fresh session is ready to build, lint,
18+
and test the Node.js tooling packages.
1819

1920
See the "Environment & Bootstrap" section of `AGENTS.md` for the manual steps and
2021
for why native iOS/Android builds are not part of the default bootstrap.

0 commit comments

Comments
 (0)