From 48ab696145e48269451224d165ccfd596bb39b6e Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Mon, 30 Sep 2024 23:13:59 +0200 Subject: [PATCH 01/37] module: expose `getPackageJSON` utility --- doc/api/module.md | 33 +++++++++++++++++++++ lib/internal/modules/esm/resolve.js | 2 +- lib/internal/modules/package_json_reader.js | 31 +++++++++++++------ lib/module.js | 4 +++ src/node_modules.cc | 24 +++++++++++++++ src/node_modules.h | 2 ++ test/parallel/test-get-package-json.js | 15 ++++++++++ typings/internalBinding/modules.d.ts | 16 ++++++---- 8 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 test/parallel/test-get-package-json.js diff --git a/doc/api/module.md b/doc/api/module.md index 45e027c76155c3..cd174747600829 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -217,6 +217,39 @@ added: v22.8.0 * Returns: {string|undefined} Path to the [module compile cache][] directory if it is enabled, or `undefined` otherwise. +### `module.getPackageJSON(startPath[, everything])` + + + +> Stability: 1.1 - Active Development + +* `startPath` {URL['pathname']} Where to start looking +* `everything` {boolean} Whether to return the full contents of the found package.json +* Returns: {undefined | { + data: { + name?: string, + type?: 'commonjs' | 'module' | 'none', + exports?: string | string[] | Record, + imports?: string | string[] | Record, + [key: string]?: unknown, + }, + path: URL['pathname'], +}} + +In addition to being available to users, this utility is used internally when +resolving various aspects about a module. + +```mjs +import { getPackageJSON } from 'node:module'; + +const pjson = getPackageJSON(import.meta.resolve('some-package'), true)?.data; + +pjson?.name; // 'some-package-real-name' +pjson?.types; // './index.d.ts' +``` + ### `module.isBuiltin(moduleName)` > Stability: 1.1 - Active Development From c865d558f6e703de01adfc58287ea1d564850a1e Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Wed, 2 Oct 2024 09:26:00 +0200 Subject: [PATCH 15/37] fixup: americanize name --- lib/internal/modules/esm/resolve.js | 2 +- lib/internal/modules/package_json_reader.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index ca038673aa3f63..2bbb16dc803387 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -191,7 +191,7 @@ const legacyMainResolveExtensionsIndexes = { * 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node) * 5. NOT_FOUND * @param {URL} packageJSONUrl - * @param {import('typings/internalBinding/modules').RecognisedPackageConfig} packageConfig + * @param {import('typings/internalBinding/modules').RecognizedPackageConfig} packageConfig * @param {string | URL | undefined} base * @returns {URL} */ diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js index 85a780c8bf7289..5ae015f8fa813b 100644 --- a/lib/internal/modules/package_json_reader.js +++ b/lib/internal/modules/package_json_reader.js @@ -16,14 +16,14 @@ const { /** * @typedef {import('typings/internalBinding/modules').FullPackageConfig} FullPackageConfig - * @typedef {import('typings/internalBinding/modules').RecognisedPackageConfig} RecognisedPackageConfig + * @typedef {import('typings/internalBinding/modules').RecognizedPackageConfig} RecognizedPackageConfig * @typedef {import('typings/internalBinding/modules').SerializedPackageConfig} SerializedPackageConfig */ /** * @param {string} path * @param {SerializedPackageConfig} contents - * @returns {RecognisedPackageConfig} + * @returns {RecognizedPackageConfig} */ function deserializePackageJSON(path, contents) { if (contents === undefined) { @@ -88,7 +88,7 @@ function deserializePackageJSON(path, contents) { * specifier?: URL | string, * isESM?: boolean, * }} options - * @returns {RecognisedPackageConfig} + * @returns {RecognizedPackageConfig} */ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) { // This function will be called by both CJS and ESM, so we need to make sure @@ -107,7 +107,7 @@ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) { * @deprecated Expected to be removed in favor of `read` in the future. * Behaves the same was as `read`, but appends package.json to the path. * @param {string} requestPath - * @return {RecognisedPackageConfig} + * @return {RecognizedPackageConfig} */ function readPackage(requestPath) { // TODO(@anonrig): Remove this function. @@ -120,7 +120,7 @@ function readPackage(requestPath) { * @param {URL['href'] | URL['pathname']} startPath The path to start searching from. * @param {boolean} everything Whether to include the full contents of the package.json. * @returns {undefined | { - * data: everything extends true ? FullPackageConfig : RecognisedPackageConfig, + * data: everything extends true ? FullPackageConfig : RecognizedPackageConfig, * path: URL['pathname'], * }} */ @@ -166,7 +166,7 @@ function getNearestParentPackageJSON(startPath, everything = false) { /** * Returns the package configuration for the given resolved URL. * @param {URL | string} resolved - The resolved URL. - * @returns {RecognisedPackageConfig} - The package configuration. + * @returns {RecognizedPackageConfig} - The package configuration. */ function getPackageScopeConfig(resolved) { const result = modulesBinding.getPackageScopeConfig(`${resolved}`); From a9bf39346ca7a073798024e40255cd526d643b2e Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:25:18 +0200 Subject: [PATCH 16/37] fixup: mangle md --- doc/api/module.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/api/module.md b/doc/api/module.md index e60d93e097603f..bed8124732a34a 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -225,18 +225,18 @@ added: REPLACEME > Stability: 1.1 - Active Development -* `startPath` {URL['pathname']} Where to start looking +* `startPath` {URL\['pathname']} Where to start looking * `everything` {boolean} Whether to return the full contents of the found package.json * Returns: {undefined | { data: { - name?: string, - type?: 'commonjs' | 'module' | 'none', - exports?: string | string[] | Record, - imports?: string | string[] | Record, - [key: string]?: unknown, + name?: string, + type?: 'commonjs' | 'module' | 'none', + exports?: string | string\[] | Record\, + imports?: string | string\[] | Record\, + \[key: string]?: unknown, }, - path: URL['pathname'], -}} + path: URL\['pathname'], + }} In addition to being available to users, this utility is used internally when resolving various aspects about a module. From 190e3157117432cdc4ccdc7ea2dbf92a7ab54e1f Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:33:50 +0200 Subject: [PATCH 17/37] fixup: mangle c++ code --- src/node_modules.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/node_modules.cc b/src/node_modules.cc index 40f77946f29966..a48be4904d2e4e 100644 --- a/src/node_modules.cc +++ b/src/node_modules.cc @@ -314,8 +314,7 @@ const BindingData::PackageConfig* BindingData::TraverseParent( } void BindingData::GetNearestRawParentPackageJSON( - const v8::FunctionCallbackInfo& args -) { + const v8::FunctionCallbackInfo& args) { CHECK_GE(args.Length(), 1); CHECK(args[0]->IsString()); @@ -325,14 +324,13 @@ void BindingData::GetNearestRawParentPackageJSON( // Required for long paths in Windows ToNamespacedPath(realm->env(), &path_value); - auto package_json = TraverseParent( - realm, - std::filesystem::path(path_value.ToString())); + auto package_json = + TraverseParent(realm, std::filesystem::path(path_value.ToString())); if (package_json != nullptr) { Local result[2] = { - ToV8Value(realm->context(), package_json->raw_json).ToLocalChecked(), - ToV8Value(realm->context(), package_json->file_path).ToLocalChecked(), + ToV8Value(realm->context(), package_json->raw_json).ToLocalChecked(), + ToV8Value(realm->context(), package_json->file_path).ToLocalChecked(), }; args.GetReturnValue().Set(Array::New(realm->isolate(), result, 2)); From a9e3ded261c24710e87abbe07b31129ad746d001 Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Fri, 4 Oct 2024 08:56:49 +0200 Subject: [PATCH 18/37] =?UTF-8?q?fixup:=20specific=20=E2=86=92=20nondescri?= =?UTF-8?q?pt=20to=20satisfy=20linting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aviv Keller --- doc/api/module.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/module.md b/doc/api/module.md index bed8124732a34a..723bbe5a8205a9 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -225,7 +225,7 @@ added: REPLACEME > Stability: 1.1 - Active Development -* `startPath` {URL\['pathname']} Where to start looking +* `startPath` {string} Where to start looking * `everything` {boolean} Whether to return the full contents of the found package.json * Returns: {undefined | { data: { From 926b2b09042b31d9747e9dbecec666fea4f4397f Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:01:27 +0200 Subject: [PATCH 19/37] fixup: correct return dec in md --- doc/api/module.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/api/module.md b/doc/api/module.md index 723bbe5a8205a9..50cdb254c39705 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -227,16 +227,14 @@ added: REPLACEME * `startPath` {string} Where to start looking * `everything` {boolean} Whether to return the full contents of the found package.json -* Returns: {undefined | { - data: { - name?: string, - type?: 'commonjs' | 'module' | 'none', - exports?: string | string\[] | Record\, - imports?: string | string\[] | Record\, - \[key: string]?: unknown, - }, - path: URL\['pathname'], - }} +* Returns: {Object | undefined} + * data: {Object} + * name: {string} + * type: {'commonjs' | 'module' | undefined} + * exports: string | string\[] | Record\ | undefined + * imports: string | string\[] | Record\ | undefined + * \[key: string]?: {unknown} + * path: {string} In addition to being available to users, this utility is used internally when resolving various aspects about a module. From 485b1e365ab5014a89ea4064a37e108d7fc80ee7 Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sat, 5 Oct 2024 12:26:06 +0200 Subject: [PATCH 20/37] fixup: remove temp fields & correct type decs --- lib/internal/modules/package_json_reader.js | 105 ++++++++++---------- typings/internalBinding/modules.d.ts | 24 +++-- 2 files changed, 63 insertions(+), 66 deletions(-) diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js index 5ae015f8fa813b..9a206d4abec5fa 100644 --- a/lib/internal/modules/package_json_reader.js +++ b/lib/internal/modules/package_json_reader.js @@ -15,6 +15,7 @@ const { } = require('internal/errors'); /** + * @typedef {import('typings/internalBinding/modules').DeserializedPackageConfig} DeserializedPackageConfig * @typedef {import('typings/internalBinding/modules').FullPackageConfig} FullPackageConfig * @typedef {import('typings/internalBinding/modules').RecognizedPackageConfig} RecognizedPackageConfig * @typedef {import('typings/internalBinding/modules').SerializedPackageConfig} SerializedPackageConfig @@ -23,19 +24,19 @@ const { /** * @param {string} path * @param {SerializedPackageConfig} contents - * @returns {RecognizedPackageConfig} + * @returns {DeserializedPackageConfig} */ function deserializePackageJSON(path, contents) { if (contents === undefined) { return { - __proto__: null, - exists: false, - pjsonPath: path, - type: 'none', // Ignore unknown types for forwards compatibility + data: { + __proto__: null, + type: 'none', // Ignore unknown types for forwards compatibility + }, + path, }; } - let pjsonPath = path; const { 0: name, 1: main, @@ -46,40 +47,39 @@ function deserializePackageJSON(path, contents) { } = contents; // This is required to be used in getPackageScopeConfig. - if (optionalFilePath) { - pjsonPath = optionalFilePath; - } - - // The imports and exports fields can be either undefined or a string. - // - If it's a string, it's either plain string or a stringified JSON string. - // - If it's a stringified JSON string, it starts with either '[' or '{'. - const requiresJSONParse = (value) => (value !== undefined && (value[0] === '[' || value[0] === '{')); + const pjsonPath = optionalFilePath ?? path; return { - __proto__: null, - exists: true, - pjsonPath, - name, - ...(main != null && { main }), - ...(type != null && { type }), - ...(plainImports != null && { - // This getters are used to lazily parse the imports and exports fields. - get imports() { - const value = requiresJSONParse(plainImports) ? JSONParse(plainImports) : plainImports; - ObjectDefineProperty(this, 'imports', { __proto__: null, value }); - return this.imports; - }, - }), - ...(plainExports != null && { - get exports() { - const value = requiresJSONParse(plainExports) ? JSONParse(plainExports) : plainExports; - ObjectDefineProperty(this, 'exports', { __proto__: null, value }); - return this.exports; - }, - }), + data: { + __proto__: null, + name, + ...(main != null && { main }), + ...(type != null && { type }), + ...(plainImports != null && { + // This getters are used to lazily parse the imports and exports fields. + get imports() { + const value = requiresJSONParse(plainImports) ? JSONParse(plainImports) : plainImports; + ObjectDefineProperty(this, 'imports', { __proto__: null, value }); + return this.imports; + }, + }), + ...(plainExports != null && { + get exports() { + const value = requiresJSONParse(plainExports) ? JSONParse(plainExports) : plainExports; + ObjectDefineProperty(this, 'exports', { __proto__: null, value }); + return this.exports; + }, + }), + }, + path: pjsonPath, }; } +// The imports and exports fields can be either undefined or a string. +// - If it's a string, it's either plain string or a stringified JSON string. +// - If it's a stringified JSON string, it starts with either '[' or '{'. +const requiresJSONParse = (value) => (value !== undefined && (value[0] === '[' || value[0] === '{')); + /** * Reads a package.json file and returns the parsed contents. * @param {string} jsonPath @@ -119,19 +119,13 @@ function readPackage(requestPath) { * Return the package.json data and the path to the package.json file, or undefined. * @param {URL['href'] | URL['pathname']} startPath The path to start searching from. * @param {boolean} everything Whether to include the full contents of the package.json. - * @returns {undefined | { - * data: everything extends true ? FullPackageConfig : RecognizedPackageConfig, - * path: URL['pathname'], - * }} + * @returns {undefined | DeserializedPackageConfig} */ function getNearestParentPackageJSON(startPath, everything = false) { if (typeof startPath !== 'string') { throw new ERR_INVALID_ARG_TYPE('startPath', 'string', startPath); } - if ( - everything !== undefined && - typeof everything !== 'boolean' - ) { + if ( everything !== 'boolean') { throw new ERR_INVALID_ARG_TYPE('everything', 'boolean', everything); } @@ -141,9 +135,9 @@ function getNearestParentPackageJSON(startPath, everything = false) { return { data: { __proto__: null, - ...JSONParse(result[0]), + ...JSONParse(result?.[0]), }, - path: result[1], + path: result?.[1], }; } @@ -153,26 +147,27 @@ function getNearestParentPackageJSON(startPath, everything = false) { return undefined; } - const data = deserializePackageJSON(startPath, result); - - const { pjsonPath: path } = data; - - delete data.exists; - delete data.pjsonPath; - - return { data, path }; + return deserializePackageJSON(startPath, result); } /** * Returns the package configuration for the given resolved URL. * @param {URL | string} resolved - The resolved URL. - * @returns {RecognizedPackageConfig} - The package configuration. + * @returns {RecognizedPackageConfig & { + * exists: boolean, + * pjsonPath: DeserializedPackageConfig['path'], + * }} - The package configuration. */ function getPackageScopeConfig(resolved) { const result = modulesBinding.getPackageScopeConfig(`${resolved}`); if (ArrayIsArray(result)) { - return deserializePackageJSON(`${resolved}`, result); + const { data, path } = deserializePackageJSON(`${resolved}`, result); + return { + __proto__: null, + ...data, + pjsonPath: path, + }; } // This means that the response is a string diff --git a/typings/internalBinding/modules.d.ts b/typings/internalBinding/modules.d.ts index fd98c2d1538941..79b4580eebff4c 100644 --- a/typings/internalBinding/modules.d.ts +++ b/typings/internalBinding/modules.d.ts @@ -1,30 +1,32 @@ export type PackageType = 'commonjs' | 'module' | 'none' -export type RecognisedPackageConfig = { - pjsonPath: URL['pathname'] - exists: boolean - name?: string +export type RecognizedPackageConfig = { + name: string main?: any type: PackageType exports?: string | string[] | Record imports?: string | string[] | Record } -export type FullPackageConfig = RecognisedPackageConfig & { +export type FullPackageConfig = RecognizedPackageConfig & { [key: string]: unknown, } +export type DeserializedPackageConfig = { + data: everything extends true ? FullPackageConfig : RecognizedPackageConfig + path: URL['pathname'], +} export type SerializedPackageConfig = [ - RecognisedPackageConfig['name'], - RecognisedPackageConfig['main'], - RecognisedPackageConfig['type'], + RecognizedPackageConfig['name'], + RecognizedPackageConfig['main'], + RecognizedPackageConfig['type'], string | undefined, // exports string | undefined, // imports - RecognisedPackageConfig['pjsonPath'], // pjson file path + DeserializedPackageConfig['path'], // pjson file path ] export interface ModulesBinding { readPackageJSON(path: string): SerializedPackageConfig | undefined; getNearestParentPackageJSON(path: string): SerializedPackageConfig | undefined - getNearestRawParentPackageJSON(origin: URL['pathname']): [ReturnType, RecognisedPackageConfig['pjsonPath']] | undefined - getNearestParentPackageJSONType(path: string): RecognisedPackageConfig['type'] + getNearestRawParentPackageJSON(origin: URL['pathname']): [ReturnType, DeserializedPackageConfig['path']] | undefined + getNearestParentPackageJSONType(path: string): RecognizedPackageConfig['type'] getPackageScopeConfig(path: string): SerializedPackageConfig | undefined getPackageJSONScripts(): string | undefined } From f824ce9343a5678995571d5362aec502324cbda8 Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sat, 5 Oct 2024 13:29:26 +0200 Subject: [PATCH 21/37] fixup: wordsmith doc & expand examples --- doc/api/module.md | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/doc/api/module.md b/doc/api/module.md index 50cdb254c39705..deeaefebf220da 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -236,16 +236,27 @@ added: REPLACEME * \[key: string]?: {unknown} * path: {string} -In addition to being available to users, this utility is used internally when -resolving various aspects about a module. +Retreives the contents and location of the package.json closest to the supplied `startPath`; +this behaves identically to node's own lookup and consumption of package.json for a given module. ```mjs import { getPackageJSON } from 'node:module'; -const pjson = getPackageJSON(import.meta.resolve('some-package'), true)?.data; +const somePackage = getPackageJSON(import.meta.resolve('some-package'), true); -pjson?.name; // 'some-package-real-name' -pjson?.types; // './index.d.ts' +somePackage?.path; // '/…/node_modules/some-package/package.json' +somePackage?.data.name; // 'some-package-real-name' +somePackage?.data.types; // './index.d.ts' + +const thisParentPackage = getPackageJSON(import.meta.resolve('..')); + +thisParentPackage?.path; // '../../package.json' +thisParentPackage?.data.type; // 'module' + +const thisSubPackage = getPackageJSON(import.meta.url); + +thisSubPackage?.path; // './package.json' +thisSubPackage?.data.type; // 'commonjs' ``` ### `module.isBuiltin(moduleName)` From 7deeb7f54e5d23d6a46ed6aebc994db914e4d99c Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sat, 5 Oct 2024 14:50:35 +0200 Subject: [PATCH 22/37] fixup: leverage validate* utils --- lib/internal/modules/package_json_reader.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/internal/modules/package_json_reader.js b/lib/internal/modules/package_json_reader.js index 9a206d4abec5fa..aba220ee720fa1 100644 --- a/lib/internal/modules/package_json_reader.js +++ b/lib/internal/modules/package_json_reader.js @@ -9,10 +9,9 @@ const modulesBinding = internalBinding('modules'); const { resolve } = require('path'); const { kEmptyObject } = require('internal/util'); const { - codes: { - ERR_INVALID_ARG_TYPE, - }, -} = require('internal/errors'); + validateBoolean, + validateString, +} = require('internal/validators'); /** * @typedef {import('typings/internalBinding/modules').DeserializedPackageConfig} DeserializedPackageConfig @@ -122,12 +121,8 @@ function readPackage(requestPath) { * @returns {undefined | DeserializedPackageConfig} */ function getNearestParentPackageJSON(startPath, everything = false) { - if (typeof startPath !== 'string') { - throw new ERR_INVALID_ARG_TYPE('startPath', 'string', startPath); - } - if ( everything !== 'boolean') { - throw new ERR_INVALID_ARG_TYPE('everything', 'boolean', everything); - } + validateString(startPath, 'startPath'); + validateBoolean(everything, 'everything'); if (everything) { const result = modulesBinding.getNearestRawParentPackageJSON(startPath); From cf49f71712a47ec22c02b2895dd7620bebd391cd Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sat, 5 Oct 2024 14:51:01 +0200 Subject: [PATCH 23/37] =?UTF-8?q?fixup:=20`ToString`=20=E2=86=92=20`ToStri?= =?UTF-8?q?ngView=20`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/node_modules.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_modules.cc b/src/node_modules.cc index a48be4904d2e4e..e4fb240a255578 100644 --- a/src/node_modules.cc +++ b/src/node_modules.cc @@ -325,7 +325,7 @@ void BindingData::GetNearestRawParentPackageJSON( ToNamespacedPath(realm->env(), &path_value); auto package_json = - TraverseParent(realm, std::filesystem::path(path_value.ToString())); + TraverseParent(realm, std::filesystem::path(path_value.ToStringView())); if (package_json != nullptr) { Local result[2] = { From 358486cfdcb3b4bcad583ae6de94ff80f025bbca Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sat, 5 Oct 2024 15:05:01 +0200 Subject: [PATCH 24/37] fixup: support file URL strings, update arg name, add test case --- doc/api/module.md | 6 +++--- lib/internal/modules/package_json_reader.js | 6 ++++-- test/parallel/test-get-package-json.js | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/doc/api/module.md b/doc/api/module.md index deeaefebf220da..d5229f396fb61b 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -217,7 +217,7 @@ added: v22.8.0 * Returns: {string|undefined} Path to the [module compile cache][] directory if it is enabled, or `undefined` otherwise. -### `module.getPackageJSON(startPath[, everything])` +### `module.getPackageJSON(startLocation[, everything])`