Twin.macro: 'css' is not exported from 'styled-components/macro'

Created on 16 Dec 2020  路  3Comments  路  Source: ben-rogerson/twin.macro

import css using twin.macro with styled-components fails. Below is the error when running local in my machine the cra-styled-component example. It works on codesandbox, but not local.

./src/components/Button.js
Attempted import error: 'css' is not exported from 'styled-components/macro' (imported as '_css').

Most helpful comment

I'm seeing this too when I use yarn to install.
npm works fine - I'll have to look into this issue further.

You can fix it for now by using this twin config:

  "babelMacros": {
    "twin": {
      "preset": "styled-components",
      "css": {
        "from": "styled-components",
        "import": "css"
      }
    }
  },

Has babel updated something lately?

All 3 comments

I'm seeing this too when I use yarn to install.
npm works fine - I'll have to look into this issue further.

You can fix it for now by using this twin config:

  "babelMacros": {
    "twin": {
      "preset": "styled-components",
      "css": {
        "from": "styled-components",
        "import": "css"
      }
    }
  },

Has babel updated something lately?

@ben-rogerson thanks a million for the fast response.
npm works fine
To me It's failing on both yarn or npm

@ben-rogerson thanks a million for the fast response.
npm works fine
To me It's failing on both yarn or npm

I'm seeing the same. The strangest thing about it is that it works fine in one component, but fails when I try and import into another. Both components are in the same directory.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kieran-osgood picture kieran-osgood  路  5Comments

axe312ger picture axe312ger  路  7Comments

tettoffensive picture tettoffensive  路  6Comments

laclance picture laclance  路  8Comments

JoseRFelix picture JoseRFelix  路  4Comments