Import maps
Deno supports import maps.
You can use import maps with the --import-map=<FILE> CLI flag.
Example:
import_map.json
1. {
2. "imports": {
3. "fmt/": "https://deno.land/std@$STD_VERSION/fmt/"
4. }
5. }
color.ts
```ts, ignore import { red } from “fmt/colors.ts”;
console.log(red(“hello world”));
2. Then:
4. ```shell
5. $ deno run --import-map=import_map.json color.ts
To use your project root for absolute imports:
import_map.json
1. {
2. "imports": {
3. "/": "./",
4. "./": "./"
5. }
6. }
main.ts
ts, ignore
import { MyUtil } from "/util.ts";
This causes import specifiers starting with / to be resolved relative to the
import map’s URL or file path.
