Troubleshooting EISDIR error when building Next.js website on Windows

28 replies
Last updated: Feb 13, 2023
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.
Feb 10, 2023, 1:11 AM
Is it possible that you haven’t set the correct NPM permissions here? If you sun the command with
does it work?
Feb 10, 2023, 6:59 PM
i dont have access to sudo command as im on windows using git bash
Feb 10, 2023, 7:54 PM
ive just cloned and converted my project to yarn adn even then i still get the same error
Feb 10, 2023, 7:55 PM
I just installed sudo for powershell and try to run sudo yarn build and still getting the same EISDIR error
Feb 10, 2023, 8:00 PM
it is saying illegal operation on a directory, even though it is a page.tsx that it is referring to?
Feb 10, 2023, 8:01 PM
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 )?
Feb 10, 2023, 8:11 PM
uh oh, all i have is windows 😭
Feb 10, 2023, 8:19 PM
this is what the structure for the app folder looks like
Feb 10, 2023, 8:19 PM
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
Feb 10, 2023, 8:20 PM
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.
Feb 10, 2023, 8:22 PM
fab thank you,ive just made it public
Feb 10, 2023, 8:23 PM
Cool, thank you. I’m jumping into a meeting for a bit but I’ll pick this up right after.
Feb 10, 2023, 8:24 PM
thank you very much!
Feb 10, 2023, 8:26 PM
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.
Feb 10, 2023, 9:31 PM
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?
Feb 10, 2023, 9:34 PM
Feb 10, 2023, 9:34 PM
how odd, do you think it might be worth for me to reinstall vs code?
Feb 10, 2023, 9:35 PM
One thing that occurs to me: I’m using a general
for my vars, what are you using? Also, I commented out any lines in
that 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.
Feb 10, 2023, 9:43 PM
for the .env i am using a .env.local,and i will try that now with the page.tsx in the slug directory
Feb 10, 2023, 9:49 PM
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?
Feb 10, 2023, 9:55 PM
I think it’s to do with the explanation in the answer here .
Feb 10, 2023, 9:58 PM
Basically, it looks like npm does not have access to that directory because it somehow got custom settings in your
Feb 10, 2023, 9:59 PM
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?
Feb 10, 2023, 10:09 PM
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
Feb 10, 2023, 10:10 PM
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!
Feb 10, 2023, 10:24 PM
Glad we got there! It’s a really weird issue I hadn’t come across before.
Feb 10, 2023, 10:31 PM
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
Feb 11, 2023, 12:07 AM
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!
Feb 13, 2023, 5:05 PM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?

Categorized in