Yarn berry can't find type in module

15 Views Asked by At

When installing packages with yarn berry(v3.6.3), I encountered an error where types couldn't be imported.
Although there were no issues in vscode, when running the React app with 'yarn start', the following error occurred: a

"Module not found: Error: Package path ./dist/types is not exported from package /Users/user/project/.yarn/cache/class-variance-authority-npm-0.7.0-1a63840197-e7fd1fab43.zip/node_modules/class-variance-authority..."

Below is the problematic code.

import { ClassValue } from 'class-variance-authority/dist/types';

When installed via npm, I could directly import types from 'class-variance-authority', but with yarn berry, I had to go into the dist/types folder to import types. Though, an error occurred when executing the code.

Environment yarn: 3.6.3 npm: 9.6.7 node: 18.17.1 typescript: 4.4.2

0

There are 0 best solutions below