dantheman
dantheman•3w ago

Configure a deno.json to disregard package.json?

I have a few projects where a small Deno backend serves APIs for a classic Vite frontend (react, eslint, typescript, etc). So I have my backend dependencies in deno.json while all of the numerous toolchain deps are in package.json. This has been a pretty clean setup, however Deno has the annoying habit of also reading package.json and adding stuff from it to deno.lock. Recently I've also begun using JSR packages in package.json for my frontend app, which makes Deno crash out. I've started setting DENO_NO_PACKAGE_JSON=1 in my CI and terminals to address this. But I can't see how to set it more properly in deno.json so it always applies. And now I'm seeing that the deno LSP is starting to complain too! I don't know how to set DENO_NO_PACKAGE_JSON=1 on the LSP. So when I try importing an npm module in Deno, it complaints that the package.json is using a JSR module. Any advice on using package.json and deno.json independently in the same repo?
No description
4 Replies
marvinh.
marvinh.•3w ago
Yes, use two separate folders
dantheman
danthemanOP•3w ago
The advantage of a single source tree is that I can easily import the API types in the backend and also the frontend. If I move either project into a subfolder then that becomes harder I'm trying to share code without merging the dependencies :/
marvinh.
marvinh.•3w ago
sounds like a perfect use case for workspaces: https://docs.deno.com/runtime/fundamentals/workspaces/
dantheman
danthemanOP•3w ago
ok I'll have to take a look. I don't know if it solves my problem of deno poking its nose into package.json/node_modules but it looks otherwise helpful 🙂

Did you find this page helpful?