LiRiK
LiRiK2y ago

./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
No description
50 Replies
erquhart
erquhart2y ago
Have you made any edits to your convex/tsconfig.json? What do you have under compilerOptions.target
ballingt
ballingt2y ago
Also curious about your non-Convex directory tsconfig.json
LiRiK
LiRiKOP2y ago
I tried making changes to this file, but it didn't help.
No description
LiRiK
LiRiKOP2y ago
No description
LiRiK
LiRiKOP2y ago
Are you more comfortable with screenshots or is it better for me to send the code in text?
erquhart
erquhart2y ago
This is fine. Nothing is jumping out at me as to why you'd be getting that type error. Still looking
LiRiK
LiRiKOP2y ago
This is the complete output of the npm run build command
LiRiK
LiRiKOP2y ago
Maybe this will help you figure it out?
ballingt
ballingt2y ago
What version of TypeScript are you using?
erquhart
erquhart2y ago
Something is happening not in line with your tsconfigs
LiRiK
LiRiKOP2y ago
"typescript": "^5"
erquhart
erquhart2y ago
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
erquhart
erquhart2y ago
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...
LiRiK
LiRiKOP2y ago
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?
erquhart
erquhart2y ago
Doubtful A stretch, but try deleting the next cache and rebuilding locally (delete .next folder)
LiRiK
LiRiKOP2y ago
I changed this and the error with edge runtime disappeared.
No description
LiRiK
LiRiKOP2y ago
And tell me, how to do this would be more correct, first run npm run dev or npx convex dev?
erquhart
erquhart2y ago
hmm I would not have expected that to be case sensitive, but yeah that checks out
LiRiK
LiRiKOP2y ago
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)
erquhart
erquhart2y ago
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
LiRiK
LiRiKOP2y ago
No description
LiRiK
LiRiKOP2y ago
Ok, sec Haha, the error remained, but now the edge runtime error has returned again
erquhart
erquhart2y ago
What did you change that led to the error disappearing, and what has changed since
LiRiK
LiRiKOP2y ago
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
erquhart
erquhart2y ago
Do the dev commands work?
LiRiK
LiRiKOP2y ago
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
erquhart
erquhart2y ago
Where did the dom.iterable entry come from in your root tsconfig Curious if dropping that could help
LiRiK
LiRiKOP2y ago
I'm sorry, I don't understand what you're talking about
erquhart
erquhart2y ago
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 error
LiRiK
LiRiKOP2y ago
I deleted the VSC doesn't swear, I need to clean it up .next?
erquhart
erquhart2y ago
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
LiRiK
LiRiKOP2y ago
I deleted it, visual studio code will not give an error
erquhart
erquhart2y ago
Error from deleting it would either be in next build or at runtime in the browser
ballingt
ballingt2y ago
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"?
erquhart
erquhart2y ago
oh good catch - and replace dom.iterable when you do, that was a reach
LiRiK
LiRiKOP2y ago
No description
erquhart
erquhart2y ago
Yeah put dom.iterable back, try Tom's suggestion compilerOptions.target: "ES6" in your root tsconfig
LiRiK
LiRiKOP2y ago
I returned it but the error remained Haha
LiRiK
LiRiKOP2y ago
No description
LiRiK
LiRiKOP2y ago
Haha
erquhart
erquhart2y ago
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
LiRiK
LiRiKOP2y ago
OMG
erquhart
erquhart2y ago
drop target: "ES6" from your root tsconfig lol don't say it's working
LiRiK
LiRiKOP2y ago
It works on ES2022 LoL
LiRiK
LiRiKOP2y ago
No description
erquhart
erquhart2y ago
that makes zero sense, the failure was due to being below ES2015 full build worked?
LiRiK
LiRiKOP2y ago
To be honest, I do not know, but it seems like this is my first build of next
No description
LiRiK
LiRiKOP2y ago
Well, it looks kind of normal.
erquhart
erquhart2y ago
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
LiRiK
LiRiKOP2y ago
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

Did you find this page helpful?