Install a local deno package
I want to use a local deno package as a dependency in a second local deno package, and I don't want to include the first package's imports as dependencies of my second package.
To spell it out, say I am developing a local package
foo
located at stuff/foo/deno.json
which has a few imports from jsr, npm, etc.
Now I have another project stuff/bar/deno.json
and the file stuff/bar/main.ts
contains import * from "foo"
.
How do I make foo
resolve to my local package?
If I have "foo": "/full/path/to/stuff/foo/entrypoint.ts"
under "imports"
in stuff/bar/deno.json
, then deno run stuff/bar/entrypoint.ts
complains that it can't find all the jsr, npm, etc dependencies of my first project.
I've tried hosting foo
on GitHub, but this doesn't actually change anything.
I've tried bundling foo
, but that's a whole different can of worms that produces ridiculous bundle sizes.
Surely importing other local deno packages is possible?5 Replies
Try
Make sure the deno.json of foo has a matching version in your boo's imports.
Foo doesn't need to be actually published but the name and version do need to match.
This would be a perfect work-around, but it seems that the package
@b/foo
does have to be published on jsr
. I'm using deno 2.1.4, maybe this feature is new?
(I recieve error: JSR package not found: @b/foo
)
(Related: https://discord.com/channels/684898665143206084/1320145666478968937)No, the package doesn't need to be published to use the
patch
feature. The target folder just needs to have a deno.json
with the relevant pacakge metadata in it. The package does not need to be publishedWhat does the deno.json of
@b/foo
look like?
Can you show both deno.json files?My first package, which I want to reuse, has deno.json:
(Omitting
task
, compilerOptions
and fmt
entries.)
The second package, which uses the first package as a dependency, has deno.json:
The patch url is correct, because it errors clearly if it isn't. Otherwise, deno run
in my second package produces error: JSR package not found: @jollywatt/zettelbuilder