emotion-js / emotion

👩‍🎤 CSS-in-JS library designed for high performance style composition
https://emotion.sh/
MIT License
17.5k stars 1.11k forks source link

@emotion/cache can't be resolved after pnpm installation of a React & Vite project with @emotion/react #2993

Open itayperry opened 1 year ago

itayperry commented 1 year ago

Current behavior:

import createCache from '@emotion/cache'; produces an error:

image

To reproduce: 1) Create a new vite & react project: pnpm create vite my-react-app --template react-ts 2) Then:
pnpm install @mui/material @emotion/react @emotion/styled 3) Try importing createCache: import createCache from '@emotion/cache';

Expected behavior:

import createCache from '@emotion/cache'; is supposed to work without installing @emotion/cache

Environment information:

image

Andarist commented 1 year ago

import createCache from '@emotion/cache'; is supposed to work without installing @emotion/cache

This is impossible with pnpm. It's the whole point of pnpm that you can't just access random packages and hope for the best.

itayperry commented 1 year ago

import createCache from '@emotion/cache'; is supposed to work without installing @emotion/cache

This is impossible with pnpm. It's the whole point of pnpm that you can't just access random packages and hope for the best.

So the right thing to do is to install pnpm i @emotion/cache? @Andarist

Andarist commented 1 year ago

Yes.

itayperry commented 1 year ago

Yes.

Oh I see!! Thank you very much @Andarist ⚡️

itayperry commented 1 year ago

pnpm is getting really famous and widespread now, I think this should be added to the docs... avoiding users from experiencing this issue.