OokerO
Deno2y ago
Ooker

The deployment failed: Relative import path "$fresh/server.ts" not prefixed with / or ./ or ../

When deploying I get this error:
Deploying... (100.0%)
Error: The deployment failed: Relative import path "$fresh/server.ts" not prefixed with / or ./ or ../

A person who had the same error on their machine solves this by adding this to the import map:
  "deno.importMap": "./import_map.json"

This doesn't work on my case. In my understanding this shouldn't be an issue at all. Do you know why is that?

Background

My fresh project is under some sub-folder from the root. The structure is like this:
.
├── .github
├── .git
└── deno.json/
    └── 1/
        └── Web/
            ├── main.ts
            └── dev.ts

deno.json

{
  "lock": false,
  "tasks": {
    "check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
    "cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
    "manifest": "deno task cli manifest $(pwd)",
    "start": "deno run -A --watch=static/,routes/ './1/Web/dev.ts'",
    "build": "deno run -A './1/Web/dev.ts' build",
    "preview": "deno run -A ./1/Web/main.ts",
    "update": "deno run -A -r https://fresh.deno.dev/update ."
  },
...
  "exclude": [
    "**/_fresh/*"
  ],
  "imports": {
    "$fresh/": "https://deno.land/x/fresh@1.6.1/",
    "preact": "https://esm.sh/preact@10.19.2",
    "preact/": "https://esm.sh/preact@10.19.2/",
    "@preact/signals": "https://esm.sh/*@preact/signals@1.2.1",
    "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.0",
    "tailwindcss": "npm:tailwindcss@3.3.5",
    "tailwindcss/": "npm:/tailwindcss@3.3.5/",
    "tailwindcss/plugin": "npm:/tailwindcss@3.3.5/plugin.js",
    "$std/": "https://deno.land/std@0.208.0/",
    "daisyui": "npm:daisyui@4.4.19"
  },
...
Stack Overflow
I have this TypeScript complaint in my editor for a Deno module.

Relative import path "$fresh/dev.ts" not prefixed with / or ./ or ../

There is an import_map.json with this content.
{
...
Was this page helpful?