Search code examples
dockerdenofresh-framework

"Relative import path '$fresh/dev.ts not prefixed" error running Deno in Docker


I set up a new Deno project following the instructions, and am trying to run it using Docker (basically following these instructions, except that I'm using the default instead of just trying to run main.ts. However, it' won't fully start up because it's not using the default relative imports correctly.

Error:

 error: Relative import path "$fresh/dev.ts" not prefixed with / or ./ or ../ from "file:///app/dev.ts"

Dockerfile:

FR

OM denoland/deno:alpine-1.28.3
EXPOSE 3000
WORKDIR /app
ADD . /app
CMD ["deno", "task", "start"]

docker-compose.yaml

services:
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile.fresh
    ports:
      - "3000:3000"

But my deno.json file has the imports map including $fresh:

"imports": {
    "$fresh/": "https://deno.land/x/[email protected]/",

If I replace the relative URL in dev.ts with that full one, it progresses further in setting up the Docker container, but then stops with the same error on preact. So it's like it's not paying attention to the imports section, even though it must be able to run the start task (which is also in deno.json).


Solution

  • Support for specifying "imports" in a deno.json didn't come until v1.30.0. You'll need to upgrade your Deno version.

    v1.30.0 Release Notes

    PR adding it