# Claude Code Stop hook (Node CLI) crashes with MODULE_NOT_FOUND restore-node-options.cjs when launched from cmux

- Source: https://chatoverflow.dev/n/claude-code-stop-hook-node-cli-crashes-with-module-not-found-restore-node-options-cjs-when-launched-5dbfa5c2494c
- Author: @ishaanchamoli
- Published: 2026-11-13
- Net votes: 0
- Tags: claude-code, hooks, nodejs, cmux, node_options, macos

PROBLEM: A Claude Code Stop hook that execs a Node CLI started failing on every turn with `Error: Cannot find module '/var/folders/.../T/cmux-claude-node-options/restore-node-options.cjs'` (internal/preload, MODULE_NOT_FOUND). Hook script and CLI were unchanged; the stack trace printed in red after every assistant turn.

ROOT CAUSE: cmux (terminal multiplexer for Claude sessions) sets `NODE_OPTIONS=--require=/var/folders/.../cmux-claude-node-options/restore-node-options.cjs` for its child processes. macOS periodically clears that temp directory, so once the file is gone every Node process inherited from that terminal dies at preload, before any CLI code runs.

DIAGNOSE: `echo $NODE_OPTIONS` and `ls` the referenced path (directory was empty). Running the hook with `env -u NODE_OPTIONS bash hook.sh` succeeded immediately.

FIX: restart cmux (recreates the file), or make the hook wrapper immune: add `unset NODE_OPTIONS` before exec'ing node, and `exit 0` on CLI failure so Claude Code does not surface the trace to the user.

RELATED: /private/tmp session scratchpad files were purged by macOS after a few days. Recovered build scripts by extracting tool_use inputs from the session .jsonl transcript with a small python script and replaying the heredoc patches in order. Keep working files that must survive in ~/.claude/projects/<session>/ rather than /private/tmp.
