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

[Bug?]: node:test not recognised as built-in module by @yarnpkg/doctor #6343

Closed
1 task done
bradleyayers opened this issue Jun 14, 2024 · 2 comments · Fixed by #6347
Closed
1 task done

[Bug?]: node:test not recognised as built-in module by @yarnpkg/doctor #6343

bradleyayers opened this issue Jun 14, 2024 · 2 comments · Fixed by #6347
Labels
bug Something isn't working

Comments

@bradleyayers
Copy link
Contributor

bradleyayers commented Jun 14, 2024

Self-service

  • I'd be willing to implement a fix

Describe the bug

I'm importing the node:test module, but doctor gives me an error saying it's an undeclared dependency.

To reproduce

  1. Create a file with import "node:test".
  2. Run doctor

Environment

System:
  OS: macOS 14.5
  CPU: (10) arm64 Apple M1 Max
Binaries:
  Node: 21.6.1 - /private/var/folders/fs/c9jy5p9s6cvg_2hv2x2gn5pc0000gn/T/xfs-446a8e07/node
  Yarn: 4.2.2 - /private/var/folders/fs/c9jy5p9s6cvg_2hv2x2gn5pc0000gn/T/xfs-446a8e07/yarn
  npm: 10.2.4 - ~/.proto/shims/npm

Additional context

It looks like because this module is only importable as node:test and not as just test, this code

...(Module.builtinModules || []).map(mod => `node:${mod}`),
does not cater for it. node:test also isn't listed in require("module").builtinModules.

@bradleyayers bradleyayers added the bug Something isn't working label Jun 14, 2024
@arcanis
Copy link
Member

arcanis commented Jun 14, 2024

The check here should be replaced by a call to isBuiltin

@bradleyayers
Copy link
Contributor Author

The docs say isBuiltin was added in 18.6.0, and https://github.com/yarnpkg/berry/blob/master/packages/yarnpkg-doctor/package.json#L45 indicates doctor supports 18.2.0, should I bump the engines field too?

bradleyayers added a commit to bradleyayers/berry that referenced this issue Jun 15, 2024
This swaps to use `isBuiltin` from Node rather than constructing a
custom set of module names with `node:` prefix. For some modules that
didn't have a "bare" module (e.g. `node:test`) this fixes false positive
errors.

Closes yarnpkg#6343
arcanis added a commit that referenced this issue Jun 19, 2024
This swaps to use `isBuiltin` from Node rather than constructing a
custom set of module names with `node:` prefix. For some modules that
didn't have a "bare" module (e.g. `node:test`) this fixes false positive
errors.

## What's the problem this PR addresses?

<!-- Describe the rationale of your PR. -->
<!-- Link all issues that it closes. (Closes/Resolves #xxxx.) -->

Closes #6343

## How did you fix it?

<!-- A detailed description of your implementation. -->

## Checklist

<!--- Don't worry if you miss something, chores are automatically
tested. -->
<!--- This checklist exists to help you remember doing the chores when
you submit a PR. -->
<!--- Put an `x` in all the boxes that apply. -->
- [ ] I have read the [Contributing
Guide](https://yarnpkg.com/advanced/contributing).

<!-- See
https://yarnpkg.com/advanced/contributing#preparing-your-pr-to-be-released
for more details. -->
<!-- Check with `yarn version check` and fix with `yarn version check
-i` -->
- [ ] I have set the packages that need to be released for my changes to
be effective.

<!-- The "Testing chores" workflow validates that your PR follows our
guidelines. -->
<!-- If it doesn't pass, click on it to see details as to what your PR
might be missing. -->
- [ ] I will check that all automated PR checks pass before the PR gets
reviewed.

---------

Co-authored-by: Maël Nison <nison.mael@gmail.com>
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.

2 participants