[msw v2] Module not found: Package path ./node is not exported from package
Unanswered
Devon Rex posted this in #help-forum
Devon RexOP
We recently migrated our web app and one of its dependencies (next-widgets) to
Not being an expert, to me it is a bit weird what is going on. I asked
What would be the next steps to try to understand what is missing here?
msw latest version. The dependency (next-widgets) makes problems since then, when I try to build the web app with next build:`
> next build
Skipping linting
✓ Checking validity of types
Failed to compile.
./node_modules/@biomedit/next-widgets/esm/lib/testUtils.js
Module not found: Package path ./node is not exported from package
/Users/christianr/Documents/workspace/portal/frontend/node_modules/msw (see exports field in
/Users/christianr/Documents/workspace/portal/frontend/node_modules/msw/package.json)
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./node_modules/@biomedit/next-widgets/esm/lib/index.js
./node_modules/@biomedit/next-widgets/esm/index.js
./pages/404.tsx
> Build failed because of webpack errors
Creating an optimized production build .%Not being an expert, to me it is a bit weird what is going on. I asked
msw support channel, did not get any answer so far. I tried a couple of things without any success. My rough guess is that following import import { setupServer } from 'msw/node'; does not get correctly exported in the third party library. Or it correctly gets exported but Next.js does tree-shaking on it (after having read https://nextjs.org/docs/messages/module-not-found )? Fact is: I am able to run the tests (Jest) with this msw latest version. Only application building is problematic. What would be the next steps to try to understand what is missing here?