fix(examples): exclude node_modules from example copy to prevent duplicate React#84
Merged
Merged
Conversation
…icate React The generate-example script copies the source example directory into dist/, including node_modules with pnpm symlinks that still point back to the source location. When pnpm install runs in dist/ it finds the lockfile up-to-date and reuses the stale symlinks as-is. This causes packages like connectkit to resolve React from the source directory while the app uses React from the dist directory — two different React instances — leading to a "Cannot read properties of null (reading 'useRef')" error during Next.js prerendering. Filter out node_modules and .next during the copy so pnpm install creates a clean dependency tree in the dist directory. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
danielrx-echo
approved these changes
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generate-example.mjsscript was copying the source example'snode_modules(containing pnpm symlinks pointing to the source directory) intodist/. Sincepnpm installfound the lockfile up-to-date, it reused the stale symlinks, causing packages likeconnectkitto resolve React from the source directory while the app used its own copy — two React instances — triggeringTypeError: Cannot read properties of null (reading 'useRef')during Next.js prerendering.node_modulesand.nextduring the copy sopnpm installcreates a clean dependency tree.Test Plan
node examples/scripts/generate-example.mjs nextjs-evmbuilds successfully (was failing before)node examples/scripts/generate-example.mjs react-evmstill builds successfullyconnectkit's React resolves to the dist directory's copy (not the source directory's)🤖 Generated with Claude Code