Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto enable byonm for Node.js projects #22316

Closed
littledivy opened this issue Feb 7, 2024 · 3 comments
Closed

Auto enable byonm for Node.js projects #22316

littledivy opened this issue Feb 7, 2024 · 3 comments
Labels
cli related to cli/ dir node compat

Comments

@littledivy
Copy link
Member

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/next@13.5.6/node_modules/next/dist/cli/next-dev.js:83:15)
    at ChildProcess.<anonymous> (file:///Users/divy/gh/my-app/node_modules/.deno/next@13.5.6/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:

  1. Default to BYONM behaviour if package.json or node_modules exists.

  2. Detect packages installed in node_modules and use BYONM. Use global cache behaviour for packages that are not installed.

  3. Add subcommand similar to npm install that will install to local node_modules/ if package.json exists and enable BYONM.

  4. Do nothing & Try to improve the error message.

@birkskyum
Copy link
Contributor

birkskyum commented Mar 19, 2024

Yep, hit this again today when trying to run this example:

https://github.com/toeverything/blocksuite/tree/master/examples/react-basic-next

Just went deno task dev in the example repo, and it crash - it would be fantastic to have this work out-of-the-box without having to worry about deno flags.

@bartlomieju
Copy link
Member

We have discussed this extensively last night and we have a tentative plan of action how to enable it. Stay tuned for more details in the coming weeks.

@dsherret
Copy link
Member

Let's track this in #23151

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir node compat
Projects
None yet
Development

No branches or pull requests

4 participants