fix-broken-next-symlinks

Diagnose and fix broken .next/node_modules symlinks from Turbopack and pnpm production assemblies.

1.5k|242|Updated Feb 16, 2017
One-click install
npx skills add https://github.com/growilabs/growi --skill fix-broken-next-symlinks
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: fix-broken-next-symlinks
Source: https://github.com/growilabs/growi/tree/main/apps/app/.claude/skills/learned/fix-broken-next-symlinks
Command: npx skills add https://github.com/growilabs/growi --skill fix-broken-next-symlinks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Turbopack externalizes packages into .next/node_modules as symlinks that can break after production assembly excludes devDependencies, causing CI or production builds to fail when symlink targets are missing.

Core Features & Use Cases

  • Reproduce and diagnose the broken symlink failure locally by running the build, assembling production artifacts, and executing the symlink checker.
  • Decision guidance to determine whether a package should be allowlisted because it is client-only or moved from devDependencies to dependencies.
  • Verification workflow that enforces the required build → assemble-prod.sh → check-next-symlinks.sh sequence to confirm resolution.
  • Use case: Resolve CI failures where dynamically imported client packages (for example socket.io-client) are externalized by Turbopack and omitted from production installs.

Quick Start

Reproduce the failure with a local build, run assemble-prod.sh, run the symlink checker, then either add the package to the allowlist or move it to dependencies and re-run the verification sequence.

Frequently Asked Questions about fix-broken-next-symlinks

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why do broken symlinks in .next/node_modules break my Next.js production builds?

Broken symlinks occur because Turbopack externalizes packages into .next/node_modules, and production assemblies exclude devDependencies, leaving symlinks pointing to missing targets. This causes CI or production builds to fail when dynamically imported client packages are omitted.

How do I fix broken .next/node_modules symlinks in a pnpm monorepo?

Reproduce the failure locally using the build → assemble-prod.sh → check-next-symlinks.sh sequence, then either add the missing package to the checker allowlist or migrate it from devDependencies to dependencies, and re-run the verification sequence to confirm resolution.

When should I allowlist a client-only package versus moving it to dependencies in pnpm?

Allowlist a package when it is strictly client-only and should not ship to production, or move it from devDependencies to dependencies when it is required at runtime. The Skill provides decision guidance based on your build → assemble-prod.sh → check-next-symlinks.sh verification workflow.

How does Turbopack externalize packages in a Next.js monorepo setup?

Turbopack externalizes packages by creating symlinks in .next/node_modules during the build process. In monorepo setups using pnpm, these symlinks can break when production assemblies exclude devDependencies, causing dynamically imported client packages like socket.io-client to point to missing targets.

Can I use this symlink fix workflow for Next.js apps without a pnpm monorepo?

This workflow specifically targets Next.js applications in monorepo setups where pnpm deploy excludes devDependencies and Turbopack creates externalized symlinks. It applies the build → assemble-prod.sh → check-next-symlinks.sh sequence to diagnose and verify broken .next/node_modules symlinks.

What limitations exist when fixing broken Turbopack symlinks in production assemblies?

The fix depends on accurately reproducing the production assembly locally using assemble-prod.sh and check-next-symlinks.sh. If a package is incorrectly allowlisted when it should be a runtime dependency, the symlink target will remain missing in production despite passing local checks.