Jammy
Jammy4d ago

SvelteKit, Deno 2 and https imports

Hello, I'm trying to use Deno 2 and SvelteKit together. When I run deno task dev vite launches the website however when I try to load a webpage I get an error about one of my imports. Here is the import in my database manager file (db.ts): import { Client } from "https://deno.land/x/postgres@v0.19.3/mod.ts"; Here is the error:
11:04:33 AM [vite] Error when evaluating SSR module /src/hooks.server.ts: failed to import "https://deno.land/x/postgres@v0.19.3/mod.ts"
|- TypeError: [ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLs are supported by the default ESM loader. Received protocol 'https'
at async nodeImport (file://.../node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:53056:15)
at async ssrImport (file://.../node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:52914:16)
at async eval (.../src/lib/db.ts, <anonymous>:3:44)
at async instantiateModule (file://.../node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:52972:5)
11:04:33 AM [vite] Error when evaluating SSR module /src/hooks.server.ts: failed to import "https://deno.land/x/postgres@v0.19.3/mod.ts"
|- TypeError: [ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLs are supported by the default ESM loader. Received protocol 'https'
at async nodeImport (file://.../node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:53056:15)
at async ssrImport (file://.../node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:52914:16)
at async eval (.../src/lib/db.ts, <anonymous>:3:44)
at async instantiateModule (file://.../node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:52972:5)
(I truncated the paths to keep the message shorter.) I tried a couple things, like adding plugins but no luck. What am I missing? svelte.config.js:
import adapter from 'svelte-adapter-deno';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: [vitePreprocess()],

kit: {
adapter: adapter()
}
};

export default config;
import adapter from 'svelte-adapter-deno';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: [vitePreprocess()],

kit: {
adapter: adapter()
}
};

export default config;
(removed comments to keep the message short) vite.config.ts:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import deno from "@deno/vite-plugin";

export default defineConfig({
plugins: [deno(), sveltekit()]
});
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import deno from "@deno/vite-plugin";

export default defineConfig({
plugins: [deno(), sveltekit()]
});
0 Replies
No replies yetBe the first to reply to this messageJoin