emilkowalski / sonner

An opinionated toast component for React.

Home Page:https://sonner.emilkowal.ski

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting module not found error on versions after 0.7.4

pranavgoel29 opened this issue · comments

Can you provide a demo with a reproduction?

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.

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",

Same issue 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.

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

As a fix import it like this

import { Toaster } from 'sonner/dist';

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

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

Screenshot 2024-04-14 at 23 10 43

Same issue here.