Emanuel | msv
Emanuel | msv4w ago

Cannot find module Error

Hello, can someone help me with the error Cannot find module 'https://deno.land/std@0.97.0/http/server.ts' or its corresponding type declarations. It works, so something is returned on the localhost page or in a get method, but can I fix this error somehow?
import { serve } from "https://deno.land/std@0.97.0/http/server.ts";

const server = serve({ port: 8000 });

console.log("HTTP webserver running. Access it at: http://localhost:8000/");

for await (const request of server) {
request.respond({ body: "Hello World\n" });
}
import { serve } from "https://deno.land/std@0.97.0/http/server.ts";

const server = serve({ port: 8000 });

console.log("HTTP webserver running. Access it at: http://localhost:8000/");

for await (const request of server) {
request.respond({ body: "Hello World\n" });
}
4 Replies
Deno AI Helper
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the error message and the code snippet you've provided, it seems like you're trying to import the serve function from a specific version of the Deno standard library. One obvious thing to check is whether the version of the standard library you are trying to import (std@0.97.0) actually exists. Deno's standard library versions are usually aligned with Deno's CLI versions. If you're using a version of Deno that's newer than 0.97.0, you might want to try updating the import URL to match the version of Deno you're using. For example, if you're using Deno 1.10.0, you would update the import to:
import { serve } from "https://deno.land/std@0.97.0/http/server.ts";
import { serve } from "https://deno.land/std@0.97.0/http/server.ts";
Please note that this advice is not based on the Deno documentation, and you should double-check the accuracy of the advice given. Make sure that the version of the standard library you are importing is compatible with your Deno version. You can find the latest version of the Deno standard library at https://deno.land/std.
Emanuel | msv
Emanuel | msv3w ago
I m using the 1.4.0 version of Deno
marvinh.
marvinh.3w ago
@Emanuel | msv the 0.97.0 version is pretty ancient being from 2021. The current version is 0.224.5, see https://jsr.io/@std/http
jeff.hykin
jeff.hykin3w ago
To be fair he's using a deno version that's nearly as ancient. All of std 0.224.5 certainly wont work for Deno 1.4.0. Sadly there are no exhaustive annotations as to what versions of deno the STD works with.