deno
deno copied to clipboard
Auto enable `byonm` for Node.js projects
Consider the default Next.js app example. A user has to know what "byonm" is to be able to run the project with Deno:
deno run -A npm:create-next-app@13 && cd my-app/
echo "{'unstable':['byonm', 'node-bare-builtins']}" >> deno.json
deno task dev
Running deno task dev without the proper features enabled will cause Deno to download node modules in global cache, leading to unexpected errors like:
divy@mini ~/g/my-app (main)> deno task dev
Task dev next dev
error: npm package '@next/swc' does not exist.
error: Uncaught (in promise) TypeError: Unknown signal: 0
at toDenoSignal (ext:deno_node/internal/child_process.ts:282:11)
at ChildProcess.kill (ext:deno_node/internal/child_process.ts:196:53)
at handleSessionStop (file:///Users/divy/gh/my-app/node_modules/.deno/[email protected]/node_modules/next/dist/cli/next-dev.js:83:15)
at ChildProcess.<anonymous> (file:///Users/divy/gh/my-app/node_modules/.deno/[email protected]/node_modules/next/dist/cli/next-dev.js:265:23)
at ChildProcess.emit (ext:deno_node/_events.mjs:383:28)
at ext:deno_node/internal/child_process.ts:180:16
at eventLoopTick (ext:core/01_core.js:65:7)
There are a few ways we could do this:
-
Default to BYONM behaviour if package.json or
node_modulesexists. -
Detect packages installed in
node_modulesand use BYONM. Use global cache behaviour for packages that are not installed. -
Add subcommand similar to
npm installthat will install to local node_modules/ if package.json exists and enable BYONM. -
Do nothing & Try to improve the error message.