Jest not recognizing Yarn workspace module

My tests run fine locally, but in CircleCI I get this error “Cannot find module ‘shared-data-model’” which is one of my Yarn workspaces.

The stack trace of the error points to Resolver.resolveModule (../node_modules/@jest/core/node_modules/jest-resolve/build/index.js:276:11)

Jest 25.1.0
Yarn 1.22
Node.js 12.16

Any ideas what could be causing this? Thank you

I figured out the problem. I am using typescript CLI tsc to transpile my module from /src to /dist, and I wasn’t running the transpile step on CI to generate the /dist folder, so when it tried to find the entrypoint of the module dist/index.js there was nothing there. Once I ran this step in CI it worked as expected.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.