error: Relative import path "@std/http/file-server" not prefixed with / or ./ or ../
I'm following this documentation to create a static files server https://docs.deno.com/examples/file_server_tutorial/
There seems to be problem with the first line of the code, which is
import { serveDir } from "@std/http/file-server";
I am getting the error
error: Relative import path "@std/http/file-server" not prefixed with / or ./ or ../
hint: If you want to use a JSR or npm package, try running
deno add jsr:@std/http/file-server
or deno add npm:@std/http/file-server
Which seems very strange to me, as its a standard library import, not anything relative.
What am I doing wrong?Deno
Write a file server
In-depth documentation, guides, and reference materials for building secure, high-performance JavaScript and TypeScript applications with Deno
3 Replies
Do I need to use deno add even when using standard lib features?
You can prepend with jsr: if you don’t want to deno add
import
s need an file to import from in Javascript/es-modules at all times.
The standard lib is a collection of modules, that you can use but are not build-in into deno
, so you need one of these in your deno.json
:
-
-
Or prefix it directly with jsr:
or npm:
in your module, like coty
said above...
- See also: https://docs.deno.com/runtime/fundamentals/configuration/#dependenciesDeno
deno.json and package.json
In-depth documentation, guides, and reference materials for building secure, high-performance JavaScript and TypeScript applications with Deno