You are viewing documentation generated from a user contribution or an upcoming release. The contents of this document may not have been reviewed by the Deno team. Click here to view the documentation for the latest release.
Edit

Import Maps

Deno supports import maps.

You can use import maps with the --import-map=<FILE> CLI flag or importMap option in the configuration file, the former will take precedence.

Example:

import_map.json

{
  "imports": {
    "fmt/": "https://deno.land/std@0.177.0/fmt/"
  }
}

color.ts

import { red } from "fmt/colors.ts";

console.log(red("hello world"));

Then:

$ deno run --import-map=import_map.json color.ts

To use your project root for absolute imports:

import_map.json

{
  "imports": {
    "/": "./",
    "./": "./"
  }
}

main.ts

import { MyUtil } from "/util.ts";

This causes import specifiers starting with / to be resolved relative to the import map's URL or file path.

Import Maps are for Applications

It is important to note that import map configuration files are only applied for Deno applications, not in the various libraries that your application code may import. This lets you, the application author, have final say about what versions of libraries get included in your project.

If you are developing a library, you should instead prefer to use the deps.ts pattern discussed in Managing Dependencies.