zing
zing•2mo 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
4 Replies
zing
zingOP•2mo 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 Khan•2mo ago
I also got the same error, it happens in the deno versions above 2.1.4
marvinh.
marvinh.•2mo 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
zing
zingOP•2mo ago
thanks for your reply. I had added that import map as part of a few initial attempts to get around this issue, and interestingly it does work using that, combined with my workaround mentioned above. Subsequently though I have removed it and tested removing some of my explicit imports from deno.json, which to my surprise has started working. So essentially my project is back in the state that it was when I first ran into this issue(at least I think it is) however it is now working. maybe something is fixed now or of course I could have been mistaken all along 🙂 thanks

Did you find this page helpful?