diff --git a/src/node_modules.cc b/src/node_modules.cc index 9217b94852e33b..9dca1857f96e43 100644 --- a/src/node_modules.cc +++ b/src/node_modules.cc @@ -363,7 +363,7 @@ void BindingData::GetPackageScopeConfig( return; } - std::string_view node_modules_package_path = "node_modules/package.json"; + std::string_view node_modules_package_path = "/node_modules/package.json"; auto error_context = ErrorContext(); error_context.is_esm = true; diff --git a/test/es-module/test-esm-resolve-type.mjs b/test/es-module/test-esm-resolve-type.mjs index 0f442ed569f848..d2642eda39062b 100644 --- a/test/es-module/test-esm-resolve-type.mjs +++ b/test/es-module/test-esm-resolve-type.mjs @@ -38,6 +38,7 @@ try { * with the defaultResolver */ [ + [ '/es-modules/package-ends-node_modules/index.js', 'module' ], [ '/es-modules/package-type-module/index.js', 'module' ], [ '/es-modules/package-type-commonjs/index.js', 'commonjs' ], [ '/es-modules/package-without-type/index.js', 'commonjs' ], diff --git a/test/fixtures/es-modules/package-ends-node_modules/index.js b/test/fixtures/es-modules/package-ends-node_modules/index.js new file mode 100644 index 00000000000000..ffd1919bb45d4b --- /dev/null +++ b/test/fixtures/es-modules/package-ends-node_modules/index.js @@ -0,0 +1,3 @@ +import os from 'os'; + +console.log(os.platform()); diff --git a/test/fixtures/es-modules/package-ends-node_modules/package.json b/test/fixtures/es-modules/package-ends-node_modules/package.json new file mode 100644 index 00000000000000..3dbc1ca591c055 --- /dev/null +++ b/test/fixtures/es-modules/package-ends-node_modules/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +}