Skip to content

fix(examples): exclude node_modules from example copy to prevent duplicate React#84

Merged
WillSewell merged 1 commit into
mainfrom
fix/generate-example-node-modules
May 5, 2026
Merged

fix(examples): exclude node_modules from example copy to prevent duplicate React#84
WillSewell merged 1 commit into
mainfrom
fix/generate-example-node-modules

Conversation

@WillSewell

Copy link
Copy Markdown
Contributor

Summary

  • The generate-example.mjs script was copying the source example's node_modules (containing pnpm symlinks pointing to the source directory) into dist/. Since pnpm install found the lockfile up-to-date, it reused the stale symlinks, causing packages like connectkit to resolve React from the source directory while the app used its own copy — two React instances — triggering TypeError: Cannot read properties of null (reading 'useRef') during Next.js prerendering.
  • Filter out node_modules and .next during the copy so pnpm install creates a clean dependency tree.

Test Plan

  • node examples/scripts/generate-example.mjs nextjs-evm builds successfully (was failing before)
  • node examples/scripts/generate-example.mjs react-evm still builds successfully
  • Verified connectkit's React resolves to the dist directory's copy (not the source directory's)

🤖 Generated with Claude Code

…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>
@WillSewell
WillSewell merged commit 3b70edc into main May 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants