Skip to content
Latchkey

Deno "Relative import path not prefixed with / or ./ or ../" in CI

Deno does not resolve bare specifiers like Node does. An import such as import x from "lodash" must be a URL, a relative path, or mapped in an import map, or Deno rejects it.

What this error means

The run fails with "error: Relative import path \"lodash\" not prefixed with / or ./ or ../ and not in import map from ...".

deno
error: Relative import path "lodash" not prefixed with / or ./ or ../ and not in import map
    at file:///home/runner/work/app/app/src/main.ts:1:19

Common causes

A bare specifier with no import map entry

Node-style bare imports are not resolved by Deno unless the name is defined in an import map (in deno.json or a mapped file).

A missing npm: or jsr: prefix

To use a package registry, the specifier needs an explicit npm: or jsr: prefix rather than a bare name.

How to fix it

Use an explicit specifier or prefix

  1. Replace the bare name with a URL, relative path, or a npm:/jsr: prefixed specifier.
  2. Re-run so Deno can resolve it.
src/main.ts
import { chunk } from "npm:lodash-es";

Map the bare name in deno.json

Define the specifier in the imports map so the bare name resolves consistently across the project.

deno.json
{
  "imports": {
    "lodash-es": "npm:lodash-es@4.17.21"
  }
}

How to prevent it

  • Prefix registry imports with npm: or jsr: explicitly.
  • Define shared bare names in the imports map in deno.json.
  • Commit deno.json so the import map is present in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →