hmt
hmt2mo ago

https imports in vite project

I want to develop my svelteKit app in deno and need to add a SQLite-module. Doing it like this:
import { DB } from "https://deno.land/x/sqlite/mod.ts";
import { DB } from "https://deno.land/x/sqlite/mod.ts";
will throw an error
[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLS are supported by the default ESM loader. Received protocol 'https'
[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLS are supported by the default ESM loader. Received protocol 'https'
How can I mix and match to get up and running?
1 Reply
Deno AI Helper
Deno AI Helper2mo ago
I apologize, but I wasn't able to find the answer to your question in the official Deno documentation. However, based on the error message you've provided, it seems like you're trying to import a Deno module using an HTTPS URL in a context that does not support such imports directly, such as a Node.js or Vite environment. The error [ERR_UNSUPPORTED_ESM_URL_SCHEME] suggests that you are running in an environment that expects local or data URLs for ES modules, not HTTP/HTTPS URLs, which is a common restriction in Node.js environments. Since you are working with a SvelteKit app, it's important to note that SvelteKit and Vite are designed to work with the Node.js ecosystem, which does not natively support importing modules via HTTPS URLs as Deno does. To work around this, you would typically need to download the module and include it in your project, or use a Node.js-compatible package from npm that provides similar functionality to the Deno module you're trying to use. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice and consult the SvelteKit or Vite documentation for more information on how to include external modules in your project.