@@ -476,7 +476,7 @@ ObjectDefineProperty(Module, '_readPackage', {
476476 * @param {string } originalPath The specifier passed to `require`
477477 */
478478function tryPackage ( requestPath , exts , isMain , originalPath ) {
479- const { main : pkg , pjsonPath } = _readPackage ( requestPath ) ;
479+ const { data : { main : pkg } , path : pjsonPath } = _readPackage ( requestPath ) ;
480480
481481 if ( ! pkg ) {
482482 return tryExtensions ( path . resolve ( requestPath , 'index' ) , exts , isMain ) ;
@@ -632,16 +632,16 @@ function resolveExports(nmPath, request) {
632632 RegExpPrototypeExec ( EXPORTS_PATTERN , request ) || kEmptyObject ;
633633 if ( ! name ) { return ; }
634634 const pkgPath = path . resolve ( nmPath , name ) ;
635- const pkg = _readPackage ( pkgPath ) ;
636- if ( pkg . exists && pkg . exports != null ) {
635+ const { data : pkg , path : pjsonPath } = _readPackage ( pkgPath ) ;
636+ if ( pkg . type !== 'none' && pkg . exports != null ) {
637637 try {
638638 const { packageExportsResolve } = require ( 'internal/modules/esm/resolve' ) ;
639639 return finalizeEsmResolution ( packageExportsResolve (
640- pathToFileURL ( pkgPath + '/package.json' ) , '.' + expansion , pkg , null ,
640+ pathToFileURL ( pjsonPath ) , '.' + expansion , pkg , null ,
641641 getCjsConditions ( ) ) , null , pkgPath ) ;
642642 } catch ( e ) {
643643 if ( e . code === 'ERR_MODULE_NOT_FOUND' ) {
644- throw createEsmNotFoundErr ( request , pkgPath + '/package.json' ) ;
644+ throw createEsmNotFoundErr ( request , pjsonPath ) ;
645645 }
646646 throw e ;
647647 }
0 commit comments