emilkowalski / sonner

An opinionated toast component for React.
https://sonner.emilkowal.ski
MIT License
8.73k stars 278 forks source link

Getting module not found error on versions after 0.7.4 #231

Open pranavgoel29 opened 12 months ago

pranavgoel29 commented 12 months ago

image

emilkowalski commented 12 months ago

Can you provide a demo with a reproduction?

cyu2019 commented 12 months ago

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 commented 12 months ago

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 commented 11 months ago

Same issue here.

konstantinkreft commented 10 months ago

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 commented 7 months ago

As a fix import it like this

import { Toaster } from 'sonner/dist';
eliamaino-fp commented 7 months ago

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

ErikBooij commented 7 months ago

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

Screenshot 2024-04-14 at 23 10 43
gaaabor commented 7 months ago

Same issue here.

inolopesm commented 3 months ago

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