How to import a path with npm specifiers? #17004
-
It's apparently possible to achieve this: import uniq from "https://cdn.skypack.dev/[email protected]/uniq"
console.log(uniq([1,2,2,3])) // [1,2,3] With the npm specifiers, it's also possible to import a whole package from npm: import uniq from "npm:[email protected]"
console.log(uniq([1,2,2,3])) // [1,2,3] Do we have a way to achieve: // It currently doesn't work for me
import uniq from "npm:[email protected]/uniq"
console.log(uniq([1,2,2,3])) // [1,2,3] |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
You should be able to use import map like so: {
"imports": {
"lodash/": "npm:/[email protected]"
}
} import uniq from "lodash/uniq"; This was fixed in #16754, notice the slash after |
Beta Was this translation helpful? Give feedback.
-
I think your example should work as-is, #15578 should have added support for this back in August. If it isn't working, you might want to file a bug report. |
Beta Was this translation helpful? Give feedback.
You should be able to use import map like so:
This was fixed in #16754, notice the slash after
npm:
- it's required in import maps to map to a folder.