byonm - force use of Deno
When I use byonm enabled in my deno.json, and say I have a vite project triggered from a package.json with i.e. "deno task dev", it appears to just my code with Node.js underneath.
Is there a way to force use of deno througout, somewhat similar to what bun has with --bun flag to overwrite uses of Node.js?
2 Replies
Based on the documentation, Deno does not provide a direct way to force the use of Deno throughout a project in the same way that the
--bun
flag does in bun. However, there are several ways to ensure that Deno is being used in your project.
Firstly, you can use the Deno VSCode extension which will prompt you to enable it in a workspace if deno.json
or deno.jsonc
files are discovered. This will ensure that Deno is being used in your VSCode workspace.
Secondly, you can enable Deno in specific parts of your workspace using the Deno: Enable Paths or "deno.enablePaths"
settings. This allows you to specify which parts of your project should be Deno enabled.
Lastly, you can use the deno task
command to run tasks defined in the tasks
section of your config file. This will ensure that these tasks are run with Deno.
However, it's important to note that if your project is using npm packages or scripts defined in a package.json
file, Deno will execute these scripts and dependencies using its compatibility layer for Node.js. This is because Deno provides support for package.json
to make it easier for Node.js projects to migrate to Deno.
If you want to completely prevent Deno from resolving a package.json
file, you can use the DENO_NO_PACKAGE_JSON
environment variable. But remember, this might affect the execution of npm packages or scripts in your project.
Please note that this information is based on the documentation and there might be other ways to achieve this that are not covered in the documentation. 🦕It's an open issue, see: https://github.com/denoland/deno/issues/21110
GitHub
deno task
with package.json
launches Node · Issue #21110 · deno...$ deno run -A npm:create-next-app@latest next-app $ cd next-app $ cat '{ "unstable": ["byonm"] }' > deno.json $ deno task dev Task dev next dev ▲ Next.js 14.0.1 - Loc...