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

Version number check fails on Bun #447

Closed
robogeek opened this issue Jul 8, 2022 · 3 comments · Fixed by #450
Closed

Version number check fails on Bun #447

robogeek opened this issue Jul 8, 2022 · 3 comments · Fixed by #450
Labels

Comments

@robogeek
Copy link

robogeek commented Jul 8, 2022

I decided to give Bun a try by running the Mocha test suite of one of my packages. The very first failure was in yargs-parser like so:

$ bun run ./node_modules/mocha/bin/mocha.js test-partials.js test-parse.js test-process.js 
986 |     ? Number(process.env.YARGS_MIN_NODE_VERSION)
987 |     : 10;
988 | if (process && process.version) {
989 |     const major = Number(process.version.match(/v([^.]+)/)[1]);
990 |     if (major < minNodeVersion) {
991 |         throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
                  ^
 error: yargs parser supports a minimum Node.js version of 10. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions
      at /home/david/Projects/akasharender/mahabhuta/test/node_modules/yargs-parser/build/index.cjs:991:14
      at bun:wrap:1:16354
      at /home/david/Projects/akasharender/mahabhuta/test/node_modules/mocha/lib/cli/options.js:12:28
      at bun:wrap:1:16354
      at /home/david/Projects/akasharender/mahabhuta/test/node_modules/mocha/bin/mocha.js:13:30

Clearly, Bun isn't going to give a value for process.version that is compatible with Node.js versions. With this script

console.log(process.version);

console.log(process);

I get this output:

$ bun run pv.js 
v0.1.2
{ ... }

For reference: https://github.com/Jarred-Sumner/bun/issues/462

@bcoe
Copy link
Member

bcoe commented Jul 13, 2022

👍 sounds like we should add some feature detection for Bun.

@paperdave
Copy link
Contributor

you should use process.versions.node (bun sets this to 16.14.0 right now). if that isn't supported on old versions of node, then fallback to process.version. is that possible?

@paperdave
Copy link
Contributor

it seems process.versions (with an s) was added in v0.2.0, so i think its safe to just change all instances of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants