Troubleshooting EISDIR error when building Next.js website on Windows
28 replies
Last updated: Feb 13, 2023
J
im using the next-sanity package. when i go to build my website for production using npm run build I get an EISDIR error. please can someone help as my website blog is ready for deployment but getting blocked by this error.
Is it possible that you haven’t set the correct NPM permissions here? If you sun the command with
sudodoes it work?
J
i dont have access to sudo command as im on windows using git bash
J
ive just cloned and converted my project to yarn adn even then i still get the same error
J
I just installed sudo for powershell and try to run sudo yarn build and still getting the same EISDIR error
J
it is saying illegal operation on a directory, even though it is a page.tsx that it is referring to?
That error usually indicates that a directory doesn’t exist or that there’s a permissions issue on your machine. Since you’re using Windows, I’m guessing it’s the latter. But I unfortunately only use a Windows machine for gaming, so debugging on them is not my strong suit 😅.
Just to rule it out, can you share the relevant files where you’re embedding this in your app (
EX )?
Just to rule it out, can you share the relevant files where you’re embedding this in your app (
EX )?
J
uh oh, all i have is windows 😭
J
this is what the structure for the app folder looks like
J
ive been following the documentation closely, i think the only thing ive added/changed within the sanity studio is the theme, and adding a description block within the page schema
None of that looks out of whack. Actually, can you share the repo with me? I’ll boot up my PC and see if I get the same errors.
J
J
thank you very much!
OK, I confirmed that is does build on both my Mac and PC, so it looks like it is something particular to your setup. I’m not totally sure what needs to change, but I’ll do some digging around that error and what can fix it.
J
huh, i also tried building it using netlify from the github repo but was served the same error that i got on my vs code. just to confirm to build it i use npm run build, this is correct right?
J
how odd, do you think it might be worth for me to reinstall vs code?
One thing that occurs to me: I’m using a general
.envfor my vars, what are you using? Also, I commented out any lines in
/post/[slug]/page.tsxthat relied on external data, since my dataset obviously wasn’t going to match yours. It may be worth it to comment out the component there and reenable line by line to narrow down what’s causing it.
J
for the .env i am using a .env.local,and i will try that now with the page.tsx in the slug directory
J
so when i run the build command on my desktop i get the error that we have been talking about, the EISDIR: illegal operation.But when i run it on my laptop using a clone of it from my github, i dont get the error....
what do you think could cause the error to happen?
what do you think could cause the error to happen?
I think it’s to do with the explanation in the answer here .
Basically, it looks like npm does not have access to that directory because it somehow got custom settings in your
.npmrc
J
do you think this could be caused if my development folder was on another harddrive compared to where node was installed? e.g node and npm was installed on my C drive but i do all my coding on my i drive?
J
i've tried deleting the .npmrc file but no luck, trying to transfer my dev folder over to my main drive now to see if that might fix it
J
well the production build now works on my laptop (still not my pc, but i think thats something i can figure out). Thank you so much for your help, you've been a life saver!
J
Hi, just to add to this as a final note. the npm run build works perfectly now on my main desktop pc, turns out it hated that my development folder was on my external harddrive which is exFAT (symlinks doesnt work on exFAT only on NTFS).Once the project was moved over to my main C drive (which is NTFS), the build ran perfectly,
thanks once again, you've been great and I will definetly be using sanity again because of how great you've been
thanks once again, you've been great and I will definetly be using sanity again because of how great you've been
Really fun to work through this one with you and I’ve learned some things to keep an eye out for it if comes up with someone else! Let us know what else you end up building with Sanity!
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.