Styled components not working

#1

Hi There,

I’m trying to get started with Expo in combination with tools that I know from web. With that in mind I tried to install styled-components as I read there’s a react-native version of it available. After I installed styled-components and built a really simple styled View with it, the metro bundler is throwing an error.

Undefined is not an object (evaluating 'argv.indexOf')

When I remove the styled-components import at the top of the file, the error disappears.

Has anyone ever had this same issue?

P.S. The error only persists in a Blank expo project. When I let Expo scaffold a project with tabs already enabled, styled-components doesn’t throw any errors and works like a charm.

Thanks in advance,
Bram

#2

please share a reproducible example. i suspect this might be something to do with node_modules, try deleting package-lock.json and node_modules and installing again with a blank project

#3

You can reproduce this by creating a blank expo project. After that install styled-components. I literally didn’t do anything else.

#4

I also did what you asked. I started a new blank project, copied the package.json to the new project and installed everything fresh. Unfortunately the same issue keeps popping up.

#5
#6

i was able to resolve it by running yarn add supports-color os and then restarting expo-cli. this seems to be some issue with metro bundler (https://github.com/facebook/metro) and styled-components

2 Likes
#7

Thanks for your help! Let’s close this topic.

closed #8