mastalampeM
Denoβ€’10mo ago
mastalampe

Selective package.json Discovery in Monorepos

Hey Deno community! πŸ‘‹

I'm working with a monorepo that contains both Deno-compatible shared libraries and non-Deno projects (like Expo/React Native). I've run into an issue where Deno discovers and tries to install dependencies from ALL package.json files in the workspace:
DEBUG RS - deno_config::workspace::discovery:278 - package.json file found at '/path/to/monorepo/package.json' 
DEBUG RS - deno_config::workspace::discovery:278 - package.json file found at '/path/to/monorepo/apps/expo/package.json' 
DEBUG RS - deno_config::workspace::discovery:278 - package.json file found at '/path/to/monorepo/packages/shared-types/package.json'

This causes problems because some package.json files contain dependencies that are incompatible with Deno (like React Native dependencies).
I found that we can disable ALL package.json discovery with the DENO_NO_PACKAGE_JSON environment variable, but this is an all-or-nothing approach. What I really need is a way to tell Deno "use this package.json but ignore that one."

Has anyone else run into this issue or found a better workaround than temporarily renaming files or changing working directories?

Thanks!
Was this page helpful?