supabase: Can not build project with V2 Typing. Next js build shows "Parsing error: Invalid character" with database.types.ts file.
Was experimenting old project with Supabase-V2 Typing. Unfortunately stuck with Error in database.ts file which is database types generated by CLI tool.
Here is the error produced
./lib/database.ts
Error: Parsing error: Invalid character.
info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (4 by maintainers)
database.types.ts is generated in UTF 16 for some reason, you just need to encode it in UTF-8, if you are using VSC just click on the encoding type and encode again
context: I’ve had the same issue, using Windows 10
i had the same issue. for some reason, if u look at right corner in vs code, it says something like utf-16… i coppied the content of database.types.ts to a regular ts file and coppied it back to database.types.ts. after that, build was successfull.
Btw this is my templorary fix (for anyone experiencing the same issue): Rather than deleting the whole eslint configuration file, I just added a
.eslintignore
file in my project and entereddatabase.types.ts
in it. Better than no configuration I guess 😄That indeed is the issue
Sadly TS playground didn’t complain.
Tried to alter my eslint config in different ways, but even the base config that Next.js generates causes this error.
However, if I delete the eslint configuration file completely, the project builds without this error.
For reference, this is my current eslint config (which causes the build to fail):
And below are the variations of config options I tried (all failed with the same error):
Variation 1:
Variation 2:
Variation 3:
At this point this seems like an issue with eslint rather than the
database.types.ts
file that Supabase generates. Will post an update if I find out the reason for this error.Thanks a lot for your help @soedirgo 🙏
Nvm, might be unrelated. If you copy your
database.types.ts
to the TS playground, does it complain? Otherwise I’m not sure where to start debugging - I also couldn’t find out where the error might be coming from (eslint?).