diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-09-12 15:47:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-12 15:47:54 -0400 |
commit | 98454c1eb802b91a8c77dd97888a8994c85dfa46 (patch) | |
tree | 851f7590f14a2f54db5ef306e884cc2c64bf6f07 /ext/node/02_require.js | |
parent | a3a4760831e14307a9499d4e410cf1653b416dc1 (diff) |
fix(npm): support cjs resolution of package subpath with package.json (#15855)
Diffstat (limited to 'ext/node/02_require.js')
-rw-r--r-- | ext/node/02_require.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/node/02_require.js b/ext/node/02_require.js index f3ed266c3..578d8e873 100644 --- a/ext/node/02_require.js +++ b/ext/node/02_require.js @@ -98,7 +98,11 @@ } function tryPackage(requestPath, exts, isMain, originalPath) { - const pkg = core.ops.op_require_read_package_scope(requestPath).main; + const packageJsonPath = pathResolve( + requestPath, + "package.json", + ); + const pkg = core.ops.op_require_read_package_scope(packageJsonPath).main; if (!pkg) { return tryExtensions( pathResolve(requestPath, "index"), @@ -135,12 +139,8 @@ err.requestPath = originalPath; throw err; } else { - const jsonPath = pathResolve( - requestPath, - "package.json", - ); node.globalThis.process.emitWarning( - `Invalid 'main' field in '${jsonPath}' of '${pkg}'. ` + + `Invalid 'main' field in '${packageJsonPath}' of '${pkg}'. ` + "Please either fix that or report it to the module author", "DeprecationWarning", "DEP0128", |