React styled-components with macro TypeError: Cannot read properties of undefined (reading 'path')

Viewed 619

I have a project in React with TypeScript and I am trying to switch to Ubuntu 20.04 from Windows 10. On Windows my project runs fine. But on Ubuntu, when I try to run it with npm run start I get this error:

TypeError: /home/dragos/Desktop/project/frontend/src/components/Component.style.ts: Cannot read properties of undefined (reading 'path')

If I remove the /macro part from import styled from 'styled-components/macro' , like this import styled from 'styled-components' the project works fine. But I don't want to do that since I'm part of a team and the rest maybe need that functionality.

Node version(16.13.0) and npm version(7.24.1) are the same both on Windows and Ubuntu.

Anyone came across this before?

Edit: I added the Component.style.ts:

import { H1, H3 } from 'components';
import styled from 'styled-components/macro';

export const Img = styled.img`
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
`;

export const ImgContainer = styled.div`
  display: block;
  width: 58rem;
  height: 28rem;
  position: relative;
`;

export const TitleIpad = styled(H1)`
  @media (max-width: 767px) {
    display: none;
  }
`;
0 Answers
Related