Revadike
Revadike5d ago

Local npm package

I have a private local npm package located in /packages/my-package, which has its own npm dependencies. How can I install this in my deno project (same repository)? I'm reading it should be possible now with https://github.com/denoland/deno/issues/15624, but I dont know how to implement this. Does it require the package to be published? How do I import it?
GitHub
Issues · denoland/deno
A modern runtime for JavaScript and TypeScript. Contribute to denoland/deno development by creating an account on GitHub.
4 Replies
Revadike
RevadikeOP5d ago
@dsherret you available? I tried the following:
{
"imports": {
"@skt/entities": "npm:@skt/entities@0.0.0",
"@supabase/supabase-js": "jsr:@supabase/supabase-js@^2.49.1",
"error-serializer": "npm:error-serializer@^8.0.0",
"steam-signin": "npm:steam-signin@^1.0.5",
"steam-user": "npm:steam-user@^5.2.0"
},
"patch": [
"../../packages/entities"
],
"unstable": [
"npm-patch"
],
"nodeModulesDir": "auto"
}
{
"imports": {
"@skt/entities": "npm:@skt/entities@0.0.0",
"@supabase/supabase-js": "jsr:@supabase/supabase-js@^2.49.1",
"error-serializer": "npm:error-serializer@^8.0.0",
"steam-signin": "npm:steam-signin@^1.0.5",
"steam-user": "npm:steam-user@^5.2.0"
},
"patch": [
"../../packages/entities"
],
"unstable": [
"npm-patch"
],
"nodeModulesDir": "auto"
}
But then I get:
> deno install
error: npm package '@skt/entities' does not exist.

> deno --version
deno 2.2.11 (stable, release, x86_64-pc-windows-msvc)
v8 13.5.212.10-rusty
typescript 5.7.3
> deno install
error: npm package '@skt/entities' does not exist.

> deno --version
deno 2.2.11 (stable, release, x86_64-pc-windows-msvc)
v8 13.5.212.10-rusty
typescript 5.7.3
And if I try to import
import * as entities from '@skt/entities';
import * as entities from '@skt/entities';
I get:
failed to create the graph: Relative import path "@skt/entities" not prefixed with / or ./ or ../
at file:///index.js:7:34
failed to create the graph: Relative import path "@skt/entities" not prefixed with / or ./ or ../
at file:///index.js:7:34
Ok, so I found out supabase edge functions still run one Deno v1. I've now forced supabase to use deno v2:
Using supabase-edge-runtime-1.68.0-develop.13 (compatible with Deno v2.1.4)
However, I still can't get it to work. I keep running into the following issue:
Failed loading patch '../../packages/entities' in config 'file:///supabase/functions/'.: Could not find patch member in 'file:///packages/entities/'.
Any help would be much appreciated!
dsherret
dsherret5d ago
A limitation atm is that the package name needs to exist on npm
Revadike
RevadikeOP3d ago
really? I had that issue with deno v1, but now with v2 i have the error above Is your patch solution available in Deno v2.1.4? How should I set up my configuration in my case? Is it possible to do this with npm install instead of deno install? Or should I not? Do I need to have my local npm package published? Once successfully setup, how should I import my local npm package in my code?
marvinh.
marvinh.3d ago
Initial support for patching local npm packages landed in 2.2.5 behind an unstable flag. It's expected to be unflagged in the upcoming Deno 2.3.0 release

Did you find this page helpful?