Build fails for web apps with React and Styled-components

so this happens only with recent builds, same project settings 7-10 days ago didn’t have this issue

it’s when building the frontend with Vite this error pops up

The inferred type of X cannot be named without a reference to ../node_modules/styled-components/dist/types. This is likely not portable. A type annotation is necessary.

I understand it might be due to styled-components issue reported here

https://github.com/styled-components/styled-components/issues/5648

but that report is about version 6.3.x

while on koyeb it happens for every version say (v6.1.x) (while doesn’t happen locally except in reported versions as on their GitHub)

so i think it’s a shared issue between koyeb (probably caching problematic build versions) and styled-components recent versions

please help

to anyone who might be facing this

I solved it by changing resolution mode inside tsconfig.json of my project

adding these 2 fields

“moduleResolution”: “node”, // Changed from “bundler”

“esModuleInterop”: true,

afterwards build succeeded

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.