emotion: create-react-app failed to compile

Current behavior:

When npm install @emotion/core and/or @emotion/styled after setting up a typescript project with create-react-app the app failed to compile even though I didn’t import emotion in the project.

To reproduce:

  1. npx create-react-app vz-app --template typescript
  2. npm install --save @emotion/core @emotion/styled

Expected behavior:

Should render the create-react-app landing page correctly.

Environment information:

  • react version: 16.12.0
  • @emotion/styled version: 10.0.23

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

I think this just is caused by a fact that you install extra dependencies with npm, while the existing node_modules has been created with yarn. It’s some kind of a mismatch between those 2 installs - if I remove all node_modules & lock files and do a fresh npm install (which includes already added emotion dependencies) then everything works OK.

npm i @types/react and npm i @types/react-dom removing the error.

so npx create-react-app use yarn under the hood ? it’s pretty annoying if there is no way to specifiy if we want to use npm instead. By removing all node_modules and npm install it solved my problem so I am going to close this issue. Thank you !

found that should be the problem of emotion is missing types in its folder for version 11.1

    "@emotion/core": "10.1.1",
    "@emotion/styled": "^10.0.27",

falling back to 10.1.1 works

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

removed the error