Sean Knowles
Sean Knowles2mo ago

Workspaces issue: Error running deno run dev command while starting Oak server

Error running an Oak backend server which imports shared packages server lib I've created.
Watcher Process started.
error: Could not find a matching package for 'npm:path-to-regexp@6.2.1' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.
at https://jsr.io/@oak/oak/16.1.0/deps.ts:87:8
Watcher Process failed. Restarting on file change...
Watcher Process started.
error: Could not find a matching package for 'npm:path-to-regexp@6.2.1' in a package.json file. You must specify this as a package.json dependency when the node_modules folder is not managed by Deno.
at https://jsr.io/@oak/oak/16.1.0/deps.ts:87:8
Watcher Process failed. Restarting on file change...
When running deno run dev in my backend app in my monorepo deno workspaces project. I have shared a packages folder using workspaces (again workspaces being plugged as working on Syntax) But keep running into this error when trying to run my backend in the apps folder which imports the shared backend lib. I can't seem to use my backend shared packages because of the error above. Any ideas on how to solve it?
22 Replies
marvinh.
marvinh.2mo ago
cc @dsherret
dsherret
dsherret2mo ago
what's your setup like? Are you're using DENO_FUTURE=1 or do you have unstable-byonm set? if you're using DENO_FUTURE=1, it depends on what version of deno you have installed because that's under active development, but I believe in the latest you can run deno install to fix it. Otherwise, if you're using npm to manage your node_modules directory then you need to manually add that package as a dependency to your package.json and then install the npm dependency via npm
Sean Knowles
Sean Knowles2mo ago
I've sent DENO_FUTURE=1 in my zshrc I am using Deno canary
dsherret
dsherret2mo ago
what are you using to install your npm packages?
Sean Knowles
Sean Knowles2mo ago
Where should I run deno install in the root of the monorepo? in every project?
dsherret
dsherret2mo ago
basically anywhere in the project and it should install the same *workspace
Sean Knowles
Sean Knowles2mo ago
Wait 2 mins will circle back
dsherret
dsherret2mo ago
it should work with deno install as long as oak is in one of your deno.json files I think, otherwise it's a bug basically deno install should see that jsr:@oak/oak@16.1.0 has a dependency on that npm package and it should add it to the node_modules folder
Sean Knowles
Sean Knowles2mo ago
seanknowles@ip-192-168-0-218 ‹ main ●● › : ~/Projects/Zemili/moonrepoV3/apps/zemili/backend
[0] % deno task dev
Task dev deno run -A --watch main.ts
Watcher Process started.

🚀🚀🚀 Server launched successfully! 🚀🚀🚀
+----------------------------------------------+
A zemili-backend service is now online
Port: 3000
Service: zemili-backend
Ready for requests!
+----------------------------------------------+

seanknowles@ip-192-168-0-218 ‹ main ●● › : ~/Projects/Zemili/moonrepoV3/apps/zemili/backend
[0] % deno task dev
Task dev deno run -A --watch main.ts
Watcher Process started.

🚀🚀🚀 Server launched successfully! 🚀🚀🚀
+----------------------------------------------+
A zemili-backend service is now online
Port: 3000
Service: zemili-backend
Ready for requests!
+----------------------------------------------+

Boom issue one resolved Thank you I do have another question When deploying my application using deno deploy
dsherret
dsherret2mo ago
great! I'm not sure all this works in deno deploy at the moment. You're on the bleeding edge...
Sean Knowles
Sean Knowles2mo ago
how can we deploy our monorepo apps then? I am subbed to Deno Deploy pro plan and have about a week or two's work ready for deployment...
Sean Knowles
Sean Knowles2mo ago
No description
dsherret
dsherret2mo ago
Deno 2.0 hasn't been released, which has the DENO_FUTURE functionality, so it hasn't been added to Deno Deploy because it's unstable
Sean Knowles
Sean Knowles2mo ago
name: Deploy Zemili Service Backend
on:
push:
branches: main
pull_request:
branches: main

jobs:
deploy:
name: Deploy Backend
runs-on: ubuntu-latest

permissions:
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Set Deno Future environment variable
run: echo "DENO_FUTURE=1" >> $GITHUB_ENV

- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "zemili-service-backend"
entrypoint: "main.ts"
root: "apps/zemili/backend"
name: Deploy Zemili Service Backend
on:
push:
branches: main
pull_request:
branches: main

jobs:
deploy:
name: Deploy Backend
runs-on: ubuntu-latest

permissions:
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Set Deno Future environment variable
run: echo "DENO_FUTURE=1" >> $GITHUB_ENV

- name: Upload to Deno Deploy
uses: denoland/deployctl@v1
with:
project: "zemili-service-backend"
entrypoint: "main.ts"
root: "apps/zemili/backend"
So workspaces doesn't work yet with the deno ecosystem Are we a day away or do I rewrite the last two weeks worth of work? I am on the fences to just switch to Golang and Deploy with Koyeb as I don't have time to wait long. I really just need an estimate on when I can deploy this monorepo on Deno infra, if its a week or so away I can wait. If its months away I will rewrite and will have to build on something else.
dsherret
dsherret2mo ago
i'm not sure about the state of workspaces in deploy, but definitely setting DENO_FUTURE=1 is not supported at the moment
Sean Knowles
Sean Knowles2mo ago
Damnnnnnnnnn What would you recommend I do Migrate? If I can't deploy....
dsherret
dsherret2mo ago
for deno deploy, i'd recommend unsetting the experimental DENO_FUTURE=1 and see if it works then based on that error message you posted though, it looks like workspace support hasn't landed in deploy yet. I'll check now for sure though. You can work around it by using an import map and mapping the specifiers like "@scope/server": "../relative-path-to-package/mod.ts" just checked in on the status of workspaces and the implementation in deploy is being worked on at the moment. I don't have an estimate for when it will be supported, but you can manually write in the resolution in the meantime in the main deno.json that gets resolved in deploy https://docs.deno.com/runtime/manual/basics/import_maps/ To re-iterate, instead of relying on the automatic workspace resolution, you can manually write it in the import map (deno.json) like this:
{
"imports": {
"@scope/server": "../relative-path-to-package/mod.ts"
"@scope/server/some-export": "../relative-path-to-package/some-export.ts"
}
}
{
"imports": {
"@scope/server": "../relative-path-to-package/mod.ts"
"@scope/server/some-export": "../relative-path-to-package/some-export.ts"
}
}
then once workspace support lands in Deploy you can remove that and actually switch to workspaces
Sean Knowles
Sean Knowles2mo ago
@dsherret mmmm I think I have that already, let me post
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"jsx": "react-jsx",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
},
"imports": {
"$std/": "https://deno.land/std@0.216.0/",
"@oak/oak": "jsr:@oak/oak@^16.1.0",
"@scope/": "./packages/",
"@scope/auth": "./packages/auth/mod.ts",
"@scope/data": "./packages/data/mod.ts",
"@scope/server": "./packages/server/mod.ts",
"@std/assert": "jsr:@std/assert@1",
"autoprefixer": "npm:autoprefixer@^10.4.20",
"esbuild": "https://deno.land/x/esbuild@v0.14.0/mod.js",
"postcss": "npm:postcss@^8.4.41",
"tailwindcss": "npm:tailwindcss@^3.4.10"
},
"workspace": [
"./apps/zemili/server",
"./apps/zemili/frontend",
"./apps/zemili/backend",
"./packages/auth",
"./packages/server",
"./packages/data"
],
"fmt": {
"semicolons": "false",
"ignore": ["**/node_modules"]
},
"lint": {
"ignore": ["**/node_modules"]
}
}
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"jsx": "react-jsx",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
},
"imports": {
"$std/": "https://deno.land/std@0.216.0/",
"@oak/oak": "jsr:@oak/oak@^16.1.0",
"@scope/": "./packages/",
"@scope/auth": "./packages/auth/mod.ts",
"@scope/data": "./packages/data/mod.ts",
"@scope/server": "./packages/server/mod.ts",
"@std/assert": "jsr:@std/assert@1",
"autoprefixer": "npm:autoprefixer@^10.4.20",
"esbuild": "https://deno.land/x/esbuild@v0.14.0/mod.js",
"postcss": "npm:postcss@^8.4.41",
"tailwindcss": "npm:tailwindcss@^3.4.10"
},
"workspace": [
"./apps/zemili/server",
"./apps/zemili/frontend",
"./apps/zemili/backend",
"./packages/auth",
"./packages/server",
"./packages/data"
],
"fmt": {
"semicolons": "false",
"ignore": ["**/node_modules"]
},
"lint": {
"ignore": ["**/node_modules"]
}
}
Yes I am already hard coding to the server package. I can't seem to run Deno Install in the actions
Sean Knowles
Sean Knowles2mo ago
No description
Sean Knowles
Sean Knowles2mo ago
@dsherret https://github.com/zemili-group/moonrepoV3/actions/runs/10636277085/job/29487717483 here's a link to the latest run, it feels like its close but the shared server package is throwing....
GitHub
chore: fixing deno install - mo fixes · zemili-group/moonrepoV3@681...
Deno monorepo on deno deploy all things zemil-group - chore: fixing deno install - mo fixes · zemili-group/moonrepoV3@681872f
No description
Sean Knowles
Sean Knowles2mo ago
Yo everything deployed Boom, its working @dsherret Thanks so much for the help!
dsherret
dsherret2mo ago
sorry, I'm just away from my computer getting lunch awesome! I'm glad that worked. Yeah then once workspace support lands in deploy you can remove all that.