bombillazo
bombillazo2w ago

Issues migrating dependencies from v1.x to v2.x

Hey, I'm facing some issues when upgrading from v1.146 to v2. We have a backend monorepo that uses import_map.json files to manage dependencies per sub module in our monorepo. We don't have a package.json for Deno (only for our Next.js frontend which is still on node). We do have a deno.jsonc at the root level of our project. After upgrading to Deno v2, we get these errors when we run or try to install:
# install
error: Error in @stripe/react-stripe-js@3.1.0 parsing version requirement for dependency "react-dom": ">=16.8.0 && <=^19.0.0"
deno install
Caused by:
0: Invalid version requirement
1: Unexpected character.
>=16.8.0 && <=^19.0.0
~
# install
error: Error in @stripe/react-stripe-js@3.1.0 parsing version requirement for dependency "react-dom": ">=16.8.0 && <=^19.0.0"
deno install
Caused by:
0: Invalid version requirement
1: Unexpected character.
>=16.8.0 && <=^19.0.0
~
# run
Running service
Watcher Process started.
error: Could not find a matching package for 'npm:pg@8.12.0' in the node_modules directory. Ensure you have all your JSR and npm dependencies listed in your deno.json or package.json, then run `deno install`. Alternatively, turn on auto-install by specifying `"nodeModulesDir": "auto"` in your deno.json file.

Watcher Process started.
error: [ERR_MODULE_NOT_FOUND] Cannot find module 'file:///Users/app/node_modules/type-fest/index.js' imported from 'file:///Users/app/@types/date.types.ts'
at file:///Users/app/@types/date.types.ts:8:24
# run
Running service
Watcher Process started.
error: Could not find a matching package for 'npm:pg@8.12.0' in the node_modules directory. Ensure you have all your JSR and npm dependencies listed in your deno.json or package.json, then run `deno install`. Alternatively, turn on auto-install by specifying `"nodeModulesDir": "auto"` in your deno.json file.

Watcher Process started.
error: [ERR_MODULE_NOT_FOUND] Cannot find module 'file:///Users/app/node_modules/type-fest/index.js' imported from 'file:///Users/app/@types/date.types.ts'
at file:///Users/app/@types/date.types.ts:8:24
this is part of our import_map.json file:
{
"imports": {
"kysely": "https://esm.sh/kysely@0.27.5",
"pg": "npm:pg@8.12.0",
"query-string": "https://esm.sh/query-string@9.1.1?dts",
"remeda": "https://esm.sh/remeda@2.17.4?dts",
"stripe": "https://esm.sh/stripe@17.4.0?dts",
"type-fest": "npm:type-fest@4.30.1",
"zod": "https://deno.land/x/zod@v3.24.1/mod.ts"
}
}
{
"imports": {
"kysely": "https://esm.sh/kysely@0.27.5",
"pg": "npm:pg@8.12.0",
"query-string": "https://esm.sh/query-string@9.1.1?dts",
"remeda": "https://esm.sh/remeda@2.17.4?dts",
"stripe": "https://esm.sh/stripe@17.4.0?dts",
"type-fest": "npm:type-fest@4.30.1",
"zod": "https://deno.land/x/zod@v3.24.1/mod.ts"
}
}
What is the proper way to step Deno dependencies for v2 in a monorepo, and should we keep using import maps?
1 Reply
bombillazo
bombillazoOP2w ago
seems like it was multiple isues at the same time, a dependency with incorrect version check, and I had to add "nodeModulesDir": "auto", to my deno.jsonc file and now it works

Did you find this page helpful?