Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Default condition should be last one #840

Closed
richard-thai opened this issue Sep 24, 2024 · 3 comments · Fixed by #843
Closed

Module not found: Default condition should be last one #840

richard-thai opened this issue Sep 24, 2024 · 3 comments · Fixed by #843

Comments

@richard-thai
Copy link

richard-thai commented Sep 24, 2024

Trying to use fetch-mock with Next.js and got the following error. I did some digging and found that Webpack expects the exports default condition in package.json to be last in this list, because it is a fallback for environments where no other specific condition applies.

`
Module not found: Default condition should be last one

1 | import fetchMock from 'fetch-mock';
| ^
3 |
4 | fetchMock.mock('/test', 200);`

@richard-thai
Copy link
Author

richard-thai commented Sep 24, 2024

I manually modified the package.json file inside the node_modules directory, and the changes appear to have resolved the issue with the following modification. Please investigate. Thanks.

{ "exports": { "browser": "./dist/esm/index.js", "import": "./dist/esm/index.js", "require": "./dist/cjs/index.js", "types": "./dist/esm/types/index.d.ts", "default": "./dist/esm/index.js" },

@wheresrhys
Copy link
Owner

Thanks for pointing this out. Fix will be released soon

@richard-thai
Copy link
Author

richard-thai commented Sep 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants