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 ...".
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:19Common 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
- Replace the bare name with a URL, relative path, or a
npm:/jsr:prefixed specifier. - Re-run so Deno can resolve it.
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.
{
"imports": {
"lodash-es": "npm:lodash-es@4.17.21"
}
}How to prevent it
- Prefix registry imports with
npm:orjsr:explicitly. - Define shared bare names in the
importsmap in deno.json. - Commit deno.json so the import map is present in CI.