The deployment failed: Relative import path "$fresh/server.ts" not prefixed with / or ./ or ../
When deploying I get this error:
A person who had the same error on their machine solves this by adding this to the import map:
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:
deno.json
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.
{
...
5 Replies
.github/workflows/deploy.yaml
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 mightbe 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. 🦕
anyone?
if the path contains a space or a non-ASCII character then it yields this error:
I haven't figured out how to escape those characters.
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...