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

Failed to resolve entry for package "@zerodevx/svelte-toast" #77

Open
rickexa opened this issue May 4, 2023 · 24 comments
Open

Failed to resolve entry for package "@zerodevx/svelte-toast" #77

rickexa opened this issue May 4, 2023 · 24 comments

Comments

@rickexa
Copy link

rickexa commented May 4, 2023

I've just installed and imported this component in svelte but I get this error:

Internal server error: Failed to resolve entry for package "@zerodevx/svelte-toast". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." specifier in "@zerodevx/svelte-toast" package

simply adding import { SvelteToast } from '@zerodevx/svelte-toast' to +layout.svelte page.

I tried to figure out what that could mean but I'm pretty new to svelte/sveltekit... so I'm writing here to seek for help.

Thanks.

@hoomp3
Copy link

hoomp3 commented May 4, 2023

@rickexa did you accidentally install it as a dev dependency? I did that and got the same error, had to install with yarn add instead yarn add -D and then restart sveltekit

@rickexa
Copy link
Author

rickexa commented May 4, 2023

I indeed installed it as a dev dependency since in the readme is specified:

npm i -D @zerodevx/svelte-toast

Anyway I've just tried the normal npm i as you suggest and it seems to work properly.

Thank you very much.

@susnick
Copy link

susnick commented May 10, 2023

Same for me. Uninstalling does not fix issue. I removed all modules and started from scratch. Issue persists.

@zerodevx
Copy link
Owner

Perhaps something changed in Svelte-world. @susnick, what's your setup? Are you using SvelteKit?

@susnick
Copy link

susnick commented May 10, 2023

I am not using SvelteKit. I use the vite template, svelte-ts for my project.

@zerodevx
Copy link
Owner

I just tried on a new svelte-ts instance and it seems to work?

https://stackblitz.com/edit/vitejs-vite-zqx6gs?file=src%2FApp.svelte&terminal=dev

@susnick
Copy link

susnick commented May 10, 2023

Yes, I confirmed it works on fresh project. I tried installing on another project I had, and it gave same error, so there must be something else causing the issue. I just switched to using a different lib for toasts, and I have no issues. If you want me to assist troubleshooting for this project, I will help, just point me in direction to go.

@zerodevx
Copy link
Owner

I'm not sure how I can help. You're not providing details, and a fresh install on your mentioned setup works, so it's likely something unrelated to this repo.

If you're getting an error like:

Internal server error: Failed to resolve entry for package "@zerodevx/svelte-toast". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." specifier in "@zerodevx/svelte-toast" package

it likely indicates that you're not using a "svelte-aware" bundler setup.

@zerodevx
Copy link
Owner

If you could provide a minimal repro on stackblitz or something, then it'll be much easier to debug.

@susnick
Copy link

susnick commented May 10, 2023

So i put my project on stackblitz, and it worked fine. Ill have to spend some time to figure out why it wont work. Thanks for the assist.

@powellnorma
Copy link

Same for me. Uninstalling does not fix issue.

Fwiw, I am facing the same problem, and am also using vite

@powellnorma
Copy link

it likely indicates that you're not using a "svelte-aware" bundler setup.

What does this mean? What does this package specifiy that would need special handling?

@zerodevx
Copy link
Owner

zerodevx commented May 11, 2023

@powellnorma could you do a minimal repro of the issue in stackblitz?

Fwiw, I am facing the same problem, and am also using vite

Most people are using vite, but there are many flavours, like sveltekit, create-vite, or some other svelte-based starter template.

What does this mean? What does this package specifiy that would need special handling?

Svelte-based template must use tooling that is svelte-aware, meaning when the bundler reads the exports from package.json:

"exports": {
    ".": {
      "types": "./index.d.ts",
      "svelte": "./index.js"
    },
  //...
}

it understands that it's dealing with a svelte component.

Edit: however it seems like multiple users are facing the same issue - perhaps something changed (again) in the Svelte ecosystem in the last week or so, like a breaking PR (happens more often than you think).

@powellnorma
Copy link

could you do a minimal repro

With the following I am able to reproduce it: https://github.com/powellnorma/toast-problem

Using npm i and npm run dev, I get:

✘ [ERROR] [plugin vite:dep-scan] Failed to resolve entry for package "@zerodevx/svelte-toast". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "@zerodevx/svelte-toast" package

Thank you for investigating!

@powellnorma
Copy link

Fyi, after specifying "type": "module", in package.json and updating vite-plugin-svelte + vite it worked

@Iuriy-Budnikov
Copy link

The same issue with vite

@zerodevx
Copy link
Owner

The same issue with vite

Make sure your dependencies are updated, remove /node_modules and package-lock.json, then reinstall deps.

$ npx npm-check-updates -u
$ rm -rf node_modules
$ rm package-lock.json
$ npm i

@Jaydeep189
Copy link

@rickexa did you accidentally install it as a dev dependency? I did that and got the same error, had to install with yarn add instead yarn add -D and then restart sveltekit

This Worked! Thanks

@Spimy
Copy link

Spimy commented Aug 14, 2023

I also ran into this issue. However I was able to fix this by simply restarting the vite server so if this was installed while the server was already running, try restarting it. As for installation command, I ran yarn add @zerodevx/svelte-toast.

@kryptus36
Copy link

I ran into this as well - my solution was to:

pnpm i -D vite@latest @sveltejs/vite-plugin-svelte@latest

@Iuriy-Budnikov
Copy link

Iuriy-Budnikov commented Aug 22, 2023

Hey @zerodevx ,
It looks like an issue with using a turbo repo.
It can't resolve a path

"exports": {
".": {
"types": "./index.d.ts",
"svelte": "./index.js"
},
//...
}

@wetmarble
Copy link

I was able to resolve this issue by adding "./package.json": "./package.json" to the exports in package.json.

@secondl1ght
Copy link

I am also running into this issue and updating deps did not resolve it - I am using the latest version of SvelteKit with the Yarn package manager if that helps.

@meandrewandyou
Copy link

make sure you've updated @sveltejs/vite-plugin-svelte - that solved the issue in my case

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