zing
zing2w ago

Relative import path "oak/router" not prefixed with / or ./ or ../ and not in import map

I get the above message when attempting to deploy to Deno Deploy via github actions. The same does not occur when running locally with deno run -A src/main.ts. deploy.yaml:
# ...
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "<proj name>"
entrypoint: "./src/main.ts"
root: ""
import-map: "./deno.json"
# ...
- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "<proj name>"
entrypoint: "./src/main.ts"
root: ""
import-map: "./deno.json"
deno.json:
// ...
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/dotenv": "jsr:@std/dotenv",
"@std/path": "jsr:@std/path",
"@types/pg": "npm:@types/pg@^8.11.10",
"drizzle-kit": "npm:drizzle-kit@^0.30.1",
"drizzle-orm": "npm:drizzle-orm@^0.38.3",
"oak": "jsr:@oak/oak@17.0.0",
"dotenv": "https://deno.land/x/dotenv@v3.2.2/mod.ts",
"deno-postgres": "https://deno.land/x/postgres@v0.19.3/mod.ts",
"joi": "npm:joi@17.13.3",
"pg": "npm:pg@^8.13.1"
}
// ...
"imports": {
"@std/assert": "jsr:@std/assert@1",
"@std/dotenv": "jsr:@std/dotenv",
"@std/path": "jsr:@std/path",
"@types/pg": "npm:@types/pg@^8.11.10",
"drizzle-kit": "npm:drizzle-kit@^0.30.1",
"drizzle-orm": "npm:drizzle-orm@^0.38.3",
"oak": "jsr:@oak/oak@17.0.0",
"dotenv": "https://deno.land/x/dotenv@v3.2.2/mod.ts",
"deno-postgres": "https://deno.land/x/postgres@v0.19.3/mod.ts",
"joi": "npm:joi@17.13.3",
"pg": "npm:pg@^8.13.1"
}
src/main.ts
import { Router } from "oak/router";
// ...
import { Router } from "oak/router";
// ...
I know what the error means and I've fixed it before in other cases. From what I can see my configuration is correct, so I'm trying to figure out why I might be getting it only in the action execution. Could anyone lend an eye? thanks
3 Replies
zing
zingOP2w ago
I have figured out that explicitly adding the sub paths of the imports to my deno.json file seems to solve the issue, for example: if I want to use oak/router in main.ts, I have to add "oak/router": "jsr:@oak/oak@17.0.0/router", to deno.json(ontop of the already existing oak import). This is weird, because locally I can just have the top level oak import and deno automatically resolves jsr:@oak/oak@17.0.0/router when I specify oak/router. I wonder why this is different when deploying, perhaps something to do with deployctl?
Abdullah Khan
Abdullah Khan2d ago
I also got the same error, it happens in the deno versions above 2.1.4
marvinh.
marvinh.2d ago
@zing remove the import-map: entry in your deploy action. The deno.json file is not an import map. It's likely that it tried to parse it as such, didn't find any import and the errored

Did you find this page helpful?