denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

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

Open marvinhagemeister opened 8 months ago

marvinhagemeister commented 8 months ago

Discussed in https://github.com/denoland/fresh/discussions/2246

Originally posted by **ooker777** January 13, 2024 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](https://stackoverflow.com/a/74748824/3416774) 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` ```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" }, ... ``` # `.github/workflows/deploy.yaml` ```yaml name: Deploy on: push: branches: [main] pull_request: branches: main jobs: deploy: name: Deploy runs-on: ubuntu-latest permissions: id-token: write # Needed for auth with Deno Deploy contents: read # Needed to clone the repository steps: - name: Clone repository uses: actions/checkout@v3 - name: Install Deno uses: denoland/setup-deno@v1 with: deno-version: v1.x - name: Build step run: "deno task build" # 📝 Update the build command(s) if necessary - name: Upload to Deno Deploy uses: denoland/deployctl@v1 with: project: "tranky" # 📝 Update the deploy project name if necessary entrypoint: "./1/Web/main.ts" # 📝 Update the entrypoint if necessary ``` (Also asked on [Stack Overflow](https://stackoverflow.com/q/77814003/3416774))
ooker777 commented 7 months ago

It's because I change the source directory. If the path contains a space or a non-ASCII character then it yields this error:

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

I can't figure out how to escape those characters.

Related bug: https://github.com/denoland/fresh/issues/2292

isAdrisal commented 5 months ago

I'm getting the same issue with a non-Fresh project where the file importing with the import map is in the base directory alongside the deno.json.

error: The deployment failed: Relative import path "$std/dotenv/mod.ts" not prefixed with / or ./ or ../

./deno.json

"imports": {
    "$std/": "https://deno.land/std@0.204.0/"
  },

./env.ts

import { load } from "$std/dotenv/mod.ts";

This was all working previously (last deploy was ~1 month ago).