Adam
Adam5d ago

Deno imports failing to load

I'm making a Svelte + Deno project. I'm currently trying to use jsr:@std/encoding@^1.0.7. Every time I try to use the package I get the error seen below. This happens with most deno packages that i try to use, where it says some file is missing. It doesn't fail when using npm:@oslojs/encoding@^1.1.0 or npm:@deno/vite-plugin@^1.0.4. I guess it's because they're npm and not jsr or deno. It also happens for packages such as https://deno.land/x/jose@v5.9.6/index.ts. I've tried running deno clean then restart my pc and create a new project. It still happens there. A friend of mine does not have the problem, when running the exact same project as me.
3 Replies
marvinh.
marvinh.5d ago
By default vite doesn't know about Deno-specific resolution. To make Deno resolution work in vite a plugin is needed, see https://github.com/denoland/deno-vite-plugin . Does installing that and adding it to the vite config help?
GitHub
GitHub - denoland/deno-vite-plugin: Vite plugin to enable Deno reso...
Vite plugin to enable Deno resolution inside vite. - denoland/deno-vite-plugin
Adam
AdamOP5d ago
No, this doesn’t work. Before I added this I got some other error. Now it seems vite can only somewhat import them, when I have the package. The error above is when I do have the vite-plugin and have added the changes in vite.config.ts.
marvinh.
marvinh.5d ago
Oh ok, can you open a bug report here https://github.com/denoland/deno-vite-plugin/issues ?

Did you find this page helpful?