abi
abi7mo ago

Relative path in `npm:` specifier

I have this in my import map:
"@heroicons/react/": "npm:@heroicons/react@2.0.18/"
"@heroicons/react/": "npm:@heroicons/react@2.0.18/"
And I try to do this:
import { Bars3Icon, BellIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { Bars3Icon, BellIcon, XMarkIcon } from "@heroicons/react/24/outline";
The error.
Failed to resolve the specifier ""@heroicons/react/24/outline"" as its after-prefix portion ""24/outline"" could not be URL-parsed relative to the URL prefix "npm:@heroicons/react@2.0.18/" mapped to by the prefix "@heroicons/react/"deno(resolver-error)
Failed to resolve the specifier ""@heroicons/react/24/outline"" as its after-prefix portion ""24/outline"" could not be URL-parsed relative to the URL prefix "npm:@heroicons/react@2.0.18/" mapped to by the prefix "@heroicons/react/"deno(resolver-error)
Any ideas? Is it possible in the first place?
2 Replies
abi
abi7mo ago
As far as I can tell, this syntax is only permissible to refer to NPM package binaries... What would be the appropriate way to accomplish the same thing in Deno? Solved it. Apparently it's this syntax:
"@heroicons/react/": "npm:/@heroicons/react@2.0.18/"
"@heroicons/react/": "npm:/@heroicons/react@2.0.18/"
Cheerio
Deno AI Helper
Deno AI Helper7mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the error message you've provided, it seems like there might be an issue with how the import map is handling the relative path in the npm: specifier. The error message indicates that the after-prefix portion "24/outline" could not be URL-parsed relative to the URL prefix mapped to by "@heroicons/react/". This suggests that the import map may not be correctly resolving the relative path you're trying to use. One thing you might want to check is whether the path you're using in your import statement correctly corresponds to the file structure within the @heroicons/react package. If the file structure does not have a directory named "24" with a subdirectory "outline", then the path would not resolve correctly. Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of the advice given. It's also a good idea to consult the documentation or community resources for the @heroicons/react package to ensure that you're using the correct file paths for importing the icons.