Skip to content
Prev Previous commit
Next Next commit
add (temporary) limitation caveat to findPackageJSON doc entry
  • Loading branch information
JakobJingleheimer committed Dec 30, 2024
commit e3972d2d85888570739b1e009f56024132527201
8 changes: 6 additions & 2 deletions doc/api/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,18 @@ added: v23.2.0
* `base` {string|URL} The absolute location (`file:` URL string or FS path) of the
containing module. For CJS, use `__filename` (not `__dirname`!); for ESM, use
`import.meta.url`. You do not need to pass it if `specifier` is an `absolute specifier`.
* Returns: {string|undefined} A path if the `package.json` is found. When `startLocation`
* Returns: {string|undefined} A path if the `package.json` is found. When `specifier`
is a package, the package's root `package.json`; when a relative or unresolved, the closest
`package.json` to the `startLocation`.
`package.json` to the `specifier`.

> **Caveat**: Do not use this to try to determine module format. There are many things effecting
> that determination; the `type` field of package.json is the _least_ definitive (ex file extension
> superceeds it, and a loader hook superceeds that).

> **Caveat**: This currently leverages only the built-in default resolver; if
> [`resolve` customization hooks][resolve hook] are registered, they will not effect the resolution.
Comment thread
JakobJingleheimer marked this conversation as resolved.
Resolved
> This may change in future.
Comment thread
JakobJingleheimer marked this conversation as resolved.
Resolved

```text
/path/to/project
├ packages/
Expand Down