Current way to install -g a tool with deno add?
Hi all,
Not sure if I missed this somewhere in the docs, but perhaps someone else has the same problem, so I’ll ask: suppose I have a script that uses something from @std, let’s say, {resolve} from @std/path.
If I want to install a script
do-thing.js
and it contains import {resolve} from "@std/path"
(this is after running $ deno add jsr:@std/path
), do I have to do anything to install that as a utility?
runs without complaint, and the script ends up in the path as expected, but when I try to use it I get the error:
error: Relative import path "@std/fs" not prefixed with / or ./ or ../ hint: If you want to use a JSR or npm package, try running deno add jsr:@std/fs or deno add npm:@std/fs at file:///Users/me/do-thing.js:3:26But as mentioned above, I already had done
deno add @std/path
.
Any suggestions? TIA.2 Replies
You can just import from the full path, instead of the "relative" one (quoted that because it's not fully relative, it's from the import map)
So instead of
import {} from "@std/path"
, you'd need to do import {} from "@std/path@^{version_you_need}"
Huh interesting, thanks. I would have assumed it would have pinned to the latest version by default.