Skip to content

Symlinked directories don't work for routes inside the app folder #77463

Answered by snivels
snivels asked this question in Help
Discussion options

You must be logged in to vote

It seems like watchpack is the issue, it's using fs.lstat instead of fs.stat and is not recognizing symlinks.

Next.js itself has correct support for symlinks.

If anyone wants to use symlinks in their project, you can change the calls from .lstat( to .stat( in the following file:

node_modules\next\dist\compiled\watchpack

Then use patch-package to create a patch for your version of Next.js:

npx patch-package next

And then update your postinstall to patch packages after install:

Closing the discussion with a resolution in case anyone wants a temporary solution until watchpack updates this.

Also updated the reproduction branch to now include the patch.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by snivels
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants