@@ -1070,29 +1070,50 @@ E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s', TypeError);
10701070E ( 'ERR_INVALID_HANDLE_TYPE' , 'This handle type cannot be sent' , TypeError ) ;
10711071E ( 'ERR_INVALID_HTTP_TOKEN' , '%s must be a valid HTTP token ["%s"]' , TypeError ) ;
10721072E ( 'ERR_INVALID_IP_ADDRESS' , 'Invalid IP address: %s' , TypeError ) ;
1073- E ( 'ERR_INVALID_MODULE_SPECIFIER' , ( pkgPath , subpath ) => {
1074- assert ( subpath !== '.' ) ;
1075- return `Package subpath '${ subpath } ' is not a valid module request for the ` +
1076- `"exports" resolution of ${ pkgPath } ${ sep } package.json` ;
1073+ E ( 'ERR_INVALID_MODULE_SPECIFIER' , ( pkgPath , subpath , base = undefined ) => {
1074+ if ( subpath === undefined ) {
1075+ return `Invalid package name '${ pkgPath } ' imported from ${ base } ` ;
1076+ } else if ( base === undefined ) {
1077+ assert ( subpath !== '.' ) ;
1078+ return `Package subpath '${ subpath } ' is not a valid module request for ` +
1079+ `the "exports" resolution of ${ pkgPath } ${ sep } package.json` ;
1080+ } else {
1081+ return `Package subpath '${ subpath } ' is not a valid module request for ` +
1082+ `the "exports" resolution of ${ pkgPath } imported from ${ base } ` ;
1083+ }
10771084} , TypeError ) ;
10781085E ( 'ERR_INVALID_OPT_VALUE' , ( name , value ) =>
10791086 `The value "${ String ( value ) } " is invalid for option "${ name } "` ,
10801087 TypeError ,
10811088 RangeError ) ;
10821089E ( 'ERR_INVALID_OPT_VALUE_ENCODING' ,
10831090 'The value "%s" is invalid for option "encoding"' , TypeError ) ;
1084- E ( 'ERR_INVALID_PACKAGE_CONFIG' ,
1085- `Invalid package config %s${ sep } package.json, %s` , Error ) ;
1086- E ( 'ERR_INVALID_PACKAGE_TARGET' , ( pkgPath , key , subpath , target ) => {
1087- if ( key === '.' ) {
1088- return `Invalid "exports" main target ${ JSONStringify ( target ) } defined ` +
1091+ E ( 'ERR_INVALID_PACKAGE_CONFIG' , ( path , message , hasMessage = true ) => {
1092+ if ( hasMessage )
1093+ return `Invalid package config ${ path } ${ sep } package.json, ${ message } ` ;
1094+ else
1095+ return `Invalid JSON in ${ path } imported from ${ message } ` ;
1096+ } , Error ) ;
1097+ E ( 'ERR_INVALID_PACKAGE_TARGET' ,
1098+ ( pkgPath , key , subpath , target , base = undefined ) => {
1099+ if ( key === null ) {
1100+ if ( subpath !== '' ) {
1101+ return `Invalid "exports" target ${ JSONStringify ( target ) } defined ` +
1102+ `for '${ subpath } ' in the package config ${ pkgPath } imported from ` +
1103+ base ;
1104+ } else {
1105+ return `Invalid "exports" main target ${ target } defined in the ` +
1106+ `package config ${ pkgPath } imported from ${ base } .` ;
1107+ }
1108+ } else if ( key === '.' ) {
1109+ return `Invalid "exports" main target ${ JSONStringify ( target ) } defined ` +
10891110 `in the package config ${ pkgPath } ${ sep } package.json` ;
1090- } else {
1091- return `Invalid "exports" target ${ JSONStringify ( target ) } defined for '${
1092- StringPrototypeSlice ( key , 0 , - subpath . length || key . length ) } ' in the ` +
1111+ } else {
1112+ return `Invalid "exports" target ${ JSONStringify ( target ) } defined for '${
1113+ StringPrototypeSlice ( key , 0 , - subpath . length || key . length ) } ' in the ` +
10931114 `package config ${ pkgPath } ${ sep } package.json` ;
1094- }
1095- } , Error ) ;
1115+ }
1116+ } , Error ) ;
10961117E ( 'ERR_INVALID_PERFORMANCE_MARK' ,
10971118 'The "%s" performance mark has not been set' , Error ) ;
10981119E ( 'ERR_INVALID_PROTOCOL' ,
@@ -1203,6 +1224,9 @@ E('ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
12031224 'The ES Module loader may not return a format of \'dynamic\' when no ' +
12041225 'dynamicInstantiate function was provided' , Error ) ;
12051226E ( 'ERR_MISSING_OPTION' , '%s is required' , TypeError ) ;
1227+ E ( 'ERR_MODULE_NOT_FOUND' , ( path , base , type = 'package' ) => {
1228+ return `Cannot find ${ type } '${ path } ' imported from ${ base } ` ;
1229+ } , Error ) ;
12061230E ( 'ERR_MULTIPLE_CALLBACK' , 'Callback called multiple times' , Error ) ;
12071231E ( 'ERR_NAPI_CONS_FUNCTION' , 'Constructor must be a function' , TypeError ) ;
12081232E ( 'ERR_NAPI_INVALID_DATAVIEW_ARGS' ,
@@ -1237,12 +1261,15 @@ E('ERR_OUT_OF_RANGE',
12371261 msg += ` It must be ${ range } . Received ${ received } ` ;
12381262 return msg ;
12391263 } , RangeError ) ;
1240- E ( 'ERR_PACKAGE_PATH_NOT_EXPORTED' , ( pkgPath , subpath ) => {
1264+ E ( 'ERR_PACKAGE_PATH_NOT_EXPORTED' , ( pkgPath , subpath , base = undefined ) => {
12411265 if ( subpath === '.' ) {
12421266 return `No "exports" main resolved in ${ pkgPath } ${ sep } package.json` ;
1243- } else {
1267+ } else if ( base === undefined ) {
12441268 return `Package subpath '${ subpath } ' is not defined by "exports" in ${
12451269 pkgPath } ${ sep } package.json`;
1270+ } else {
1271+ return `Package subpath '${ subpath } ' is not defined by "exports" in ${
1272+ pkgPath } imported from ${ base } `;
12461273 }
12471274} , Error ) ;
12481275E ( 'ERR_REQUIRE_ESM' ,
0 commit comments