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

Inquirer.js doesn't work with Bun #4787

Closed
fardjad opened this issue Sep 10, 2023 · 3 comments
Closed

Inquirer.js doesn't work with Bun #4787

fardjad opened this issue Sep 10, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@fardjad
Copy link

fardjad commented Sep 10, 2023

What version of Bun is running?

1.0.0

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

Install @inquirer/prompts@3.0.4 as a dependency, and run the following snippet:

import { input } from "@inquirer/prompts";

const answer = await input({
  message: "What’s your name?",
  default: "John Doe",
});

console.log(answer);

What is the expected behavior?

It should prompt the user to input some text and read a line from stdin. It works as expected on both Node and Deno.

What do you see instead?

It throws the following error:

120 |
121 | class AsyncResource {
122 |   type;
123 |   #snapshot;
124 |
125 |   constructor(type, options) {
                             ^
TypeError: Cannot call a class constructor without |new|
      at AsyncResource (node:async_hooks:125:26)
      at run (/Users/far/Desktop/inquirer-bun/node_modules/@inquirer/core/dist/esm/lib/hook-engine.mjs:87:13)
      at workLoop (/Users/far/Desktop/inquirer-bun/node_modules/@inquirer/core/dist/esm/lib/create-prompt.mjs:77:24)
      at /Users/far/Desktop/inquirer-bun/node_modules/@inquirer/core/dist/esm/lib/create-prompt.mjs:86:20

Additional information

At this moment, the latest version of inquirer (v3.1.0) has an unrelated issue, but after manually patching the file, the same error gets thrown. That's why the example uses an older (v3.0.4) version of the package

@AverageHelper
Copy link

For the record, it seems that @inquirer/prompts@3.1.1 fixes the aforementioned unrelated issue.

@AverageHelper
Copy link

Also, some notes:

bun --bun x @inquirer/demo@latest behaves as expected on my machine. (v0.2.11 is the latest at time of writing.)

I can reproduce the issue described above with in a separate project with only @inquirer/select@1.2.11. Seems anything that depends on @inquirer/core is affected.

It seems that both @inquirer/demo and @inquirer/select depend on the same version of @inquirer/core (v5.0.0 at time of writing). I don't know yet what's making the difference, why one works and the other does not.

@Jarred-Sumner
Copy link
Collaborator

Fixed by @paperdave in #6095

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants