I’m trying to build a simple server using Deno and the Oak framework, but I am encountering the following error:
Cannot find module ‘https://deno.land/x/oak/mod.ts’ or its corresponding type declarations
Here is the code I am using:
import { Application} from "https://deno.land/x/oak/mod.ts";
import { route } from "./router.ts";
import { client } from "./mysql.ts";
client.execute("CREATE DATABASE IF NOT EXISTS hackathon");
client.execute("USE hackathon");
const app = new Application();
app.use(route.routes());
app.use((ctx) => {
ctx.response.body = "Hello World!";
});
app.listen({ port: 8000 });
I checked the docs of deno , in that they mentioned 2 different ways :
oak is available on both deno.land/x and JSR. To use from deno.land/x
, import into a module:
import { Application } from "https://deno.land/x/oak/mod.ts";
To use from JSR, import into a module:
import { Application } from "jsr:@oak/oak";
Or use the Deno CLI to add it to your project:
deno add jsr:@oak/oak
but either way its not working unable to import application using direct url or from JSR
My setup:
Deno version: deno 2.1.3 (stable, release, aarch64-apple-darwin)
Operating system: macOS
Has anyone encountered this error before? How do I resolve it so I can run my Deno Oak server?
sandeepgogarla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.