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: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.
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:orjsr:explicitly. - Define shared bare names in the
importsmap in deno.json. - Commit deno.json so the import map is present in CI.
Related guides
Deno "error: Module not found" in CIFix Deno "error: Module not found ..." in CI - Deno resolved an import specifier to a location that does not…
Deno "Import assertion type not supported" in CIFix Deno "error: Import assertion type ... not supported" in CI - a JSON or other import used an assertion/at…
Deno npm: specifier "npm package not found" in CIFix Deno "error: npm package ... not found" in CI - an npm: specifier named a package or version the npm regi…