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

Getting module not found error on versions after 0.7.4 #231

Open
pranavgoel29 opened this issue Nov 18, 2023 · 10 comments
Open

Getting module not found error on versions after 0.7.4 #231

pranavgoel29 opened this issue Nov 18, 2023 · 10 comments

Comments

@pranavgoel29
Copy link

pranavgoel29 commented Nov 18, 2023

image

@pranavgoel29 pranavgoel29 changed the title Getting module not found errror on versions after 0.7.4 Getting module not found error on versions after 0.7.4 Nov 18, 2023
@emilkowalski
Copy link
Owner

Can you provide a demo with a reproduction?

@cyu2019
Copy link

cyu2019 commented Nov 20, 2023

Hi, I actually was struggling with a similar issue today. I think is just an issue with older create-react-app projects, which has trouble interpreting the exports field as seen here.

This issue is can be resolved by adding:

"main": "./dist/index.js",
"module": "./dist/index.mjs",

back to package.json. These were removed in #136.

It would be great if these fields could be added back to support older apps.

@pranavgoel29
Copy link
Author

pranavgoel29 commented Nov 22, 2023

I have updated the react version to 18 as well, still facing the same issue.

@cyu2019 Thanks for pointing these,
I tried after changing exports back to

image

And it worked.

I have also tried the following format, it is working.

"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",

@floklein
Copy link

Same issue here.

@konstantinkreft
Copy link

konstantinkreft commented Jan 10, 2024

This issue is can be resolved by adding:

"main": "./dist/index.js",
"module": "./dist/index.mjs",

back to package.json. These were removed in #136.

It would be great if these fields could be added back to support older apps.

I second that. Found the same issue in a vite (v4) app today.

Otherwise eslint is reporting:

error  Unable to resolve path to module 'sonner'  import/no-unresolved

@danielgek
Copy link

As a fix import it like this

import { Toaster } from 'sonner/dist';

@eliamaino-fp
Copy link

eliamaino-fp commented Apr 11, 2024

Same issue as @konstantinkreft in a Vite 5.2.7 app. Importing from sonner/dist makes eslint not complaining.

@ErikBooij
Copy link

Same issue, and importing from 'sonner/dist' doesn't work either.

Screenshot 2024-04-14 at 23 10 43

@gaaabor
Copy link

gaaabor commented Apr 16, 2024

Same issue here.

@inolopesm
Copy link

inolopesm commented Aug 3, 2024

For me, installing direcly from npm, the entry "main": "./dist/index.mjs" does not appear.
When adding manually, the error disappears

w11 / node 20.16.0 / npm 10.8.1 / sonner 1.5.0

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

No branches or pull requests

10 participants