Deno "Relative import path not prefixed with / or ./ or ../"
Deno does not resolve bare module specifiers from node_modules by default. An import that is neither a URL, a node:/npm: specifier, nor prefixed with /, ./, or ../ has nowhere to resolve from unless an import map defines it.
What this error means
A run fails with "error: Relative import path \"<name>\" not prefixed with / or ./ or ../ and not in import map". It typically appears when porting Node code that imports packages by bare name.
error: Relative import path "express" not prefixed with / or ./ or ../
and not in import map from "file:///app/server.ts"
at file:///app/server.ts:1:21Common causes
Bare specifier with no import-map entry
Code written for Node uses import express from "express". Deno has no implicit node_modules resolution, so without a map entry the bare name cannot resolve.
Missing npm:/node: prefix
Deno supports npm and Node builtins via explicit npm: and node: prefixes. Omitting the prefix leaves the specifier unresolved.
How to fix it
Use an npm: or node: specifier
Prefix the import so Deno knows where to resolve it.
import express from "npm:express@4";
import { readFile } from "node:fs/promises";Map the bare name in deno.json
Alternatively, add the bare specifier to the import map so existing imports work unchanged.
{
"imports": {
"express": "npm:express@4"
}
}How to prevent it
- Prefix Node/npm imports with
npm:/node:, or map them indeno.json. - Commit
deno.jsonso the import map is consistent across runners. - Run
deno checkin CI to catch unresolved specifiers before deploy.