D
Deno

help

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

OOoker1/16/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 ../
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"
"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
.
├── .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"
},
...
{
"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
Deno - Relative import path "$fresh/dev.ts" not prefixed
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. { ...
OOoker1/16/2024
.github/workflows/deploy.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
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
DAHDeno AI Helper1/16/2024
Based on the error message you're encountering, it seems that the import map is not being correctly resolved during the deployment process. The error indicates that the import path for $fresh/server.ts is not being recognized as a valid module specifier. The import map in your deno.json file appears to be correctly mapping the $fresh/ specifier to the https://deno.land/x/fresh@1.6.1/ URL. However, the deployment process might not be picking up this import map, or there could be an issue with how the import map is being used in the context of the deployment. Here are a few steps you can take to troubleshoot this issue: 1. Ensure the import map is being used: Make sure that the import map is correctly referenced in your deno.json file and that the deployment process is aware of it. If you're using Deno Deploy, the import map should be automatically picked up from the deno.json file. 2. Check the import map's scope: Verify that the import map's scope includes the files that are using the $fresh/ specifier. Import maps can be scoped to certain directories, and if the scope is not set correctly, it might not apply to all necessary files. 3. Verify the file structure: Ensure that the file structure of your project matches the paths specified in the import map and the deno.json tasks. The error message suggests that there might be a mismatch between the expected file structure and the actual one. 4. Check for typos or errors: Double-check the import map and deno.json file for any typos or errors that might be causing the import map to not be recognized correctly. 5. Test locally: Try running your project locally with the import map to see if the issue is specific to the deployment environment. If it works locally, the problem might
DAHDeno AI Helper1/16/2024
be with the deployment setup. 6. Consult the documentation: The documentation on import maps might provide additional insights or steps to follow to ensure that your import map is being used correctly during deployment. If you've gone through these steps and the issue persists, it might be helpful to look for similar issues in the Deno community forums or GitHub issues to see if others have encountered and resolved similar problems. Additionally, you can consider reaching out to the Deno community for further assistance. 🦕
OOoker1/27/2024
anyone? 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 ../
Error: The deployment failed: Relative import path "$fresh/server.ts" not prefixed with / or ./ or ../
I haven't figured out how to escape those characters.
OOoker1/27/2024
GitHub
Error: The deployment failed: Relative import path "$fresh/server.t...
Discussed in denoland/fresh#2246 Originally posted by ooker777 January 13, 2024 When deploying I get this error: Deploying... (100.0%) Error: The deployment failed: Relative import path "$fres...

Looking for more? Join the community!

Recommended Posts
Deno Deploy: Timeout PageIs there a way to replace the standard deno deploy timeout error page? I have a use case where I allFresh, deno deploy microservices and authHi, I want to design a Fresh frontend and api working with deno microservices and auth. My proposalEventSource vs Multiplex webookI am setting up an system that needs realtime updates for potentially 100+ different resources on a rusty_v8 - how to pass data from js/v8 into rustHello, I am playing with rusty_v8, by following the examples I was able to get js eval up and runninDeno deploy - My simple mail service is giving a connection error (works fine locally or on vercel)As the title states my small email sending API is not working on deno deploy. Maybe there needs to bHow to send data from a child component to its sibling?I want create an app with two forms, each form in its own component. Users type in form 1, then the Can Deno list all functions within a script without explicit registration or annotation?. ## For context, here is how you do it for `globalThis`: ```ts Object.getOwnPropertyNames(globalThiTypescript intelisense between jupyter notebooksI've been trying to run jupyter notebooks with deno, but I've noticed that if I create a variable inhow to compress string into stringHow would i go about compressing a string? i need to compress a string but i need the compressed valFresh - Page title to LayoutHi, I have been browsing around the docs and also being new to JSX,I'm not sure what I look for. WhaWhen I use deno run I get this error: error : Permission denied (os error 13)When I use deno run I get this error: error : Permission denied (os error 13) (for '/Users/apple/LibAxios HttpsProxyAgentHello, I tryed to search but found nothing. I'm using axios with httpProxyAgent to proxy my outgoingGet input from an island, make calculus then render ?I have a route with 2 islands inside - one to get input from user - one to render data Once I've goHow can I create a seqential deno task to pass args to child task?Hi, I read the docs and created tasks in `deno.json` like this. https://docs.deno.com/runtime/manual