When I make new page called as AboutPage.js
inside pages
folder then I get some error in terminal and on my UI on my NEXT JS app
when I try to access that page.
The ERROR is:
error - Error: ENOTDIR: not a directory, access '/mnt/BEAA30A3AA305A5B/KevalActivity/Skills/Programming/Builds/JavaScript/Next JS/instagram-clone/pages/AboutPage.js/index.tsx'
and I am attaching the error image.
When I make new page called as AboutPage.js
inside pages
folder then I get some error in terminal and on my UI on my NEXT JS app
when I try to access that page.
The ERROR is:
error - Error: ENOTDIR: not a directory, access '/mnt/BEAA30A3AA305A5B/KevalActivity/Skills/Programming/Builds/JavaScript/Next JS/instagram-clone/pages/AboutPage.js/index.tsx'
and I am attaching the error image.
Share Improve this question edited Mar 2, 2022 at 15:25 juliomalves 50.6k23 gold badges178 silver badges169 bronze badges asked Mar 2, 2022 at 14:46 Keval ShahKeval Shah 671 gold badge1 silver badge10 bronze badges3 Answers
Reset to default 2this is not how you are supposed to declare new pages with Nextjs.
I refer you to this documentation about the routing system : https://nextjs/docs/routing/introduction
You should only have an AboutPage.js file in your pages directory, and then access it with url localhost:3000/aboutpage .
You are fetch or query or ...
to a file in a wrong way. In React, Next and ... you have to remove .js
from fetch
address.
As "Bloodbee" said: about.js
=> /about
And
const response = await fetch("/api/upload.js", { ... });
=>
const response = await fetch("/api/upload", { ... });
I got the same error when i was learning next js. My mistake was I used <Link href="/posts/first-post.js">this page!</Link>
instead of <Link href="/posts/first-post">this page!</Link>
. I used the file extension ".js" in href which is not the way to do it.