Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot name a folder "index" inside the app directory. #69061

Open
jazsouf opened this issue Aug 19, 2024 · 4 comments · May be fixed by #69262 or #69287
Open

Cannot name a folder "index" inside the app directory. #69061

jazsouf opened this issue Aug 19, 2024 · 4 comments · May be fixed by #69262 or #69287
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application.

Comments

@jazsouf
Copy link
Contributor

jazsouf commented Aug 19, 2024

Link to the code that reproduces this issue

https://github.com/jazsouf/redirects-test

To Reproduce

Try to build the application with a folder named index with a page.tsx inside the app directory.

Current vs. Expected behavior

Expected to build the page and navigate to the /index route.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103
  Available memory (MB): 8192
  Available CPU cores: 8
Binaries:
  Node: 22.4.1
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.5.0
Relevant Packages:
  next: 14.2.5 // Latest available version is detected (14.2.5).
  eslint-config-next: 14.2.5
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4
Next.js Config:
  output: N/A

Which area(s) are affected?

Routing

Which stage(s) are affected?

next build (local) / vercel build

Additional context

I had an issue with redirecting the home page to the "/index" page. I wanted to reproduce this issue, but actually found what I believe is the root cause: You cannot name a folder "index" inside your app router.
The build error in question:

`Error occurred prerendering page "/index". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of undefined (reading 'clientModules')`
@jazsouf jazsouf added the bug Issue was opened via the bug report template. label Aug 19, 2024
@github-actions github-actions bot added the create-next-app Related to our CLI tool for quickly starting a new Next.js application. label Aug 19, 2024
@AbhiShake1
Copy link
Contributor

AbhiShake1 commented Aug 22, 2024

I was looking into this and i observed a few things that could be useful for anyone debugging this:

  • this issue does not occur with turbopack (in the reproduction, it was working in dev mode due to --turbo flag)

@jazsouf
Copy link
Contributor Author

jazsouf commented Aug 23, 2024

Yeah, it doesn't work in regular Webpack dev mode.

This issue must be with Webpack thinking that the '/index' route belongs to the pages router.

Maybe there is a isAppRouter condition somewhere not properly set?

@AbhiShake1
Copy link
Contributor

@jazsouf if you actually mv .next/server/app/index/index/* .next/server/app/index it will work

@jazsouf
Copy link
Contributor Author

jazsouf commented Aug 26, 2024

Yes just saw the pr from @simonri . Will close this when merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. create-next-app Related to our CLI tool for quickly starting a new Next.js application.
Projects
None yet
2 participants