@@ -219,8 +219,7 @@ function parsePackageName(specifier, base) {
219219}
220220
221221function getPackageJSONURL ( specifier , base ) {
222- const { packageName, packageSubpath, isScoped } =
223- parsePackageName ( specifier , base ) ;
222+ const { packageName, packageSubpath, isScoped } = parsePackageName ( specifier , base ) ;
224223
225224 // ResolveSelf
226225 const packageConfig = getPackageScopeConfig ( base ) ;
@@ -231,8 +230,7 @@ function getPackageJSONURL(specifier, base) {
231230 }
232231 }
233232
234- let packageJSONUrl =
235- new URL ( './node_modules/' + packageName + '/package.json' , base ) ;
233+ let packageJSONUrl = new URL ( `./node_modules/${ packageName } /package.json` , base ) ;
236234 let packageJSONPath = fileURLToPath ( packageJSONUrl ) ;
237235 let lastPath ;
238236 do {
@@ -243,9 +241,10 @@ function getPackageJSONURL(specifier, base) {
243241 // Check for !stat.isDirectory()
244242 if ( stat !== 1 ) {
245243 lastPath = packageJSONPath ;
246- packageJSONUrl = new URL ( ( isScoped ?
247- '../../../../node_modules/' : '../../../node_modules/' ) +
248- packageName + '/package.json' , packageJSONUrl ) ;
244+ packageJSONUrl = new URL (
245+ `${ isScoped ? '../' : '' } ../../../node_modules/${ packageName } /package.json` ,
246+ packageJSONUrl ,
247+ ) ;
249248 packageJSONPath = fileURLToPath ( packageJSONUrl ) ;
250249 continue ;
251250 }
0 commit comments