Closed
Description
Original issue: yarnpkg/berry#943
In short, if some package has unlisted peer dependency, Jest will emit something like this (in this case it was react-router@3
and it's underlying package create-react-class
:
xxx@xxx ws % yarn test
FAIL src/index.test.js
● Test suite failed to run
Cannot find module 'react' from 'index.js'
However, Jest was able to find:
'./Router.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
at Resolver.resolveModule (../.yarn/cache/jest-resolve-npm-25.1.0-2276a075e4-2.zip/node_modules/jest-resolve/build/index.js:276:11)
at Object.<anonymous> (../.yarn/cache/create-react-class-npm-15.6.3-ae38dfa180-2.zip/node_modules/create-react-class/index.js:11:13)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.293s
Ran all test suites.
As you see, there is no information to trace the error.
True error looks like this (PNP_DEBUG_LEVEL=1
was set in environment):
As you can see, the true error is:
error: Error: A package is trying to access another package without the second one being listed as a dependency of the first one
Required package: react (via "react")
Required by: create-react-class@npm:15.6.3 (via /home/arcanis/yarn-berry-bug/.yarn/cache/create-react-class-npm-15.6.3-ae38dfa180-2.zip/node_modules/create-react-class/)