deno icon indicating copy to clipboard operation
deno copied to clipboard

Importmap issue with Deno React vite

Open dong-lufei opened this issue 3 years ago • 4 comments

https://deno.land/[email protected]/node/how_to_with_npm/react

I followed the documentation, deno showed a syntax error Relative import path "react" not prefixed with / or ./ or ../deno(import-prefix-missing)

Should I configure ImportMap in deno.json and fill in vite.config.mjs?

dong-lufei avatar Jan 26 '23 06:01 dong-lufei

Yes, you need to either add importMap to deno.json or specify it directly in deno.json (https://deno.com/blog/v1.30#denojson-becomes-an-import-map).

bartlomieju avatar Jan 27 '23 10:01 bartlomieju

I may be wrong, but I think there may be some issue related to deno install which may be related to this one as well. I've just migrated my OSS to use deno.json imports feature (https://github.com/sobanieca/jsonr/commit/f5a397d45624c7b337a55643802a218a3dac76af#diff-54337bcff4b919f6b8b4e0b0e51d06fd9124562fde88899be726c24b7e354b7c) and when I run it locally all is good: image

I have released it to deno 3rd party repository and when I try to install it I get:

image

Maybe it's something on my end, but maybe deno install has some issues with import maps handling?

sobanieca avatar Jan 27 '23 21:01 sobanieca

Ok, actually I guess the reason why my case is not working is related to the fact that deno install most likely doesn't try to find and download deno.json file?

sobanieca avatar Jan 28 '23 17:01 sobanieca

Ok, actually I guess the reason why my case is not working is related to the fact that deno install most likely doesn't try to find and download deno.json file?

Correct, it needs to be explicitly specified as an argument (we can't find config file for remote modules)

bartlomieju avatar Jan 28 '23 20:01 bartlomieju