./node_modules/convex/src/server/router.ts error
Hello everyone, when trying to build an application with the npm run build command, this error comes out, I absolutely do not understand what this is related to and why this is so. If anyone knows what the problem might be, please tell me, if necessary, I can send other project files
PS: when trying to execute the npx convex deploy --cmd 'npm run build' command, the result is the same

50 Replies
Have you made any edits to your
convex/tsconfig.json
? What do you have under compilerOptions.target
Also curious about your non-Convex directory tsconfig.json
I tried making changes to this file, but it didn't help.


Are you more comfortable with screenshots or is it better for me to send the code in text?
This is fine. Nothing is jumping out at me as to why you'd be getting that type error. Still looking
This is the complete output of the npm run build command
Maybe this will help you figure it out?
What version of TypeScript are you using?
Something is happening not in line with your tsconfigs
"typescript": "^5"
Feels like a Next issue. Looking for precedents
The error in your original post, is that on your local or in Vercel's deployment env
Possibly related: https://github.com/vercel/next.js/discussions/62412
GitHub
During
next build
, the "Checking validity of types" phase should ...Goals During next build, the "Checking validity of types" phase should respect the typescript.tsconfigPath in next.config.js Non-Goals No response Background I maintain several tsconfig f...
I tried to execute the command both locally and on the vercel platform
I also use clerk for authorization, maybe the problem is related to this?
Doubtful
A stretch, but try deleting the next cache and rebuilding locally
(delete
.next
folder)I changed this and the error with edge runtime disappeared.

And tell me, how to do this would be more correct, first run npm run dev or npx convex dev?
hmm I would not have expected that to be case sensitive, but yeah that checks out
I think the fact is that you have "ESNext" specified in the tsconfig in the convex, and I have "esnext" specified locally, I decided to change it and everything became normal)
Guessing your npm dev script just runs the next server? I haven't built with convex and next so honestly not sure of the order - run
npx convex dev
first to be sure
Likely doesn't matter, but might
Ok, sec
Haha, the error remained, but now the edge runtime error has returned again
What did you change that led to the error disappearing, and what has changed since
I changed the case of "esnext" to "ESNext", the error disappeared, then deleted the folder.next, started convex, started npm run dev, generated .next, I stopped both commands, started npm run build, the error returned
Do the dev commands work?
Absolutely, all pages, everything works, all the functionality (I wrote a board with liveblocks) which surprises me, absolutely everything works, except for the npm run build command
Where did the
dom.iterable
entry come from in your root tsconfig
Curious if dropping that could helpI'm sorry, I don't understand what you're talking about
In the tsconfig in your project root,
compilerOptions.lib
It includes ['dom', 'dom.iterable'] - I believe you should be able to drop dom.iterable
since you're using esnext, although I'm not positive. I'm curious if it's causing the iterator errorI deleted the VSC doesn't swear, I need to clean it up .next?
Not sure what you mean in the first part of your sentence there
It's very possible dom.iterable is required and this will break things even more lol
It looks to not be included in esnext
I deleted it, visual studio code will not give an error
Error from deleting it would either be in next build or at runtime in the browser
I don't see a
target: "ESNext"
in the tsconfig.json in your project root (not the one at convex/tsconfig.json). Next won't allow some changes to this file, but could you try adding target: "ES6"
?oh good catch - and replace
dom.iterable
when you do, that was a reach
Yeah put
dom.iterable
back, try Tom's suggestion
compilerOptions.target: "ES6"
in your root tsconfigI returned it but the error remained
Haha

Haha
Seems like there are multiple typechecking phases using different targets - this error wasn't happening before, meaning the target was already higher than ES6
okay
OMG
drop
target: "ES6"
from your root tsconfig
lol don't say it's workingIt works on ES2022
LoL

that makes zero sense, the failure was due to being below ES2015
full build worked?
To be honest, I do not know, but it seems like this is my first build of next

Well, it looks kind of normal.
Hey, take the win
It doesn't appear that setting the compiler target for next is discouraged anywhere, and in some places it's encouraged
OK, thank you very much, good luck with the development of convex, I'm not a professional, but I think convex is very cool. Thanks again