@@ -1074,29 +1074,50 @@ E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s', TypeError);
1074
1074
E ( 'ERR_INVALID_HANDLE_TYPE' , 'This handle type cannot be sent' , TypeError ) ;
1075
1075
E ( 'ERR_INVALID_HTTP_TOKEN' , '%s must be a valid HTTP token ["%s"]' , TypeError ) ;
1076
1076
E ( 'ERR_INVALID_IP_ADDRESS' , 'Invalid IP address: %s' , TypeError ) ;
1077
- E ( 'ERR_INVALID_MODULE_SPECIFIER' , ( pkgPath , subpath ) => {
1078
- assert ( subpath !== '.' ) ;
1079
- return `Package subpath '${ subpath } ' is not a valid module request for the ` +
1080
- `"exports" resolution of ${ pkgPath } ${ sep } package.json` ;
1077
+ E ( 'ERR_INVALID_MODULE_SPECIFIER' , ( pkgPath , subpath , base = undefined ) => {
1078
+ if ( subpath === undefined ) {
1079
+ return `Invalid package name '${ pkgPath } ' imported from ${ base } ` ;
1080
+ } else if ( base === undefined ) {
1081
+ assert ( subpath !== '.' ) ;
1082
+ return `Package subpath '${ subpath } ' is not a valid module request for ` +
1083
+ `the "exports" resolution of ${ pkgPath } ${ sep } package.json` ;
1084
+ } else {
1085
+ return `Package subpath '${ subpath } ' is not a valid module request for ` +
1086
+ `the "exports" resolution of ${ pkgPath } imported from ${ base } ` ;
1087
+ }
1081
1088
} , TypeError ) ;
1082
1089
E ( 'ERR_INVALID_OPT_VALUE' , ( name , value ) =>
1083
1090
`The value "${ String ( value ) } " is invalid for option "${ name } "` ,
1084
1091
TypeError ,
1085
1092
RangeError ) ;
1086
1093
E ( 'ERR_INVALID_OPT_VALUE_ENCODING' ,
1087
1094
'The value "%s" is invalid for option "encoding"' , TypeError ) ;
1088
- E ( 'ERR_INVALID_PACKAGE_CONFIG' ,
1089
- `Invalid package config %s${ sep } package.json, %s` , Error ) ;
1090
- E ( 'ERR_INVALID_PACKAGE_TARGET' , ( pkgPath , key , subpath , target ) => {
1091
- if ( key === '.' ) {
1092
- return `Invalid "exports" main target ${ JSONStringify ( target ) } defined ` +
1095
+ E ( 'ERR_INVALID_PACKAGE_CONFIG' , ( path , message , hasMessage = true ) => {
1096
+ if ( hasMessage )
1097
+ return `Invalid package config ${ path } ${ sep } package.json, ${ message } ` ;
1098
+ else
1099
+ return `Invalid JSON in ${ path } imported from ${ message } ` ;
1100
+ } , Error ) ;
1101
+ E ( 'ERR_INVALID_PACKAGE_TARGET' ,
1102
+ ( pkgPath , key , subpath , target , base = undefined ) => {
1103
+ if ( key === null ) {
1104
+ if ( subpath !== '' ) {
1105
+ return `Invalid "exports" target ${ JSONStringify ( target ) } defined ` +
1106
+ `for '${ subpath } ' in the package config ${ pkgPath } imported from ` +
1107
+ base ;
1108
+ } else {
1109
+ return `Invalid "exports" main target ${ target } defined in the ` +
1110
+ `package config ${ pkgPath } imported from ${ base } .` ;
1111
+ }
1112
+ } else if ( key === '.' ) {
1113
+ return `Invalid "exports" main target ${ JSONStringify ( target ) } defined ` +
1093
1114
`in the package config ${ pkgPath } ${ sep } package.json` ;
1094
- } else {
1095
- return `Invalid "exports" target ${ JSONStringify ( target ) } defined for '${
1096
- StringPrototypeSlice ( key , 0 , - subpath . length || key . length ) } ' in the ` +
1115
+ } else {
1116
+ return `Invalid "exports" target ${ JSONStringify ( target ) } defined for '${
1117
+ StringPrototypeSlice ( key , 0 , - subpath . length || key . length ) } ' in the ` +
1097
1118
`package config ${ pkgPath } ${ sep } package.json` ;
1098
- }
1099
- } , Error ) ;
1119
+ }
1120
+ } , Error ) ;
1100
1121
E ( 'ERR_INVALID_PERFORMANCE_MARK' ,
1101
1122
'The "%s" performance mark has not been set' , Error ) ;
1102
1123
E ( 'ERR_INVALID_PROTOCOL' ,
@@ -1207,6 +1228,9 @@ E('ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK',
1207
1228
'The ES Module loader may not return a format of \'dynamic\' when no ' +
1208
1229
'dynamicInstantiate function was provided' , Error ) ;
1209
1230
E ( 'ERR_MISSING_OPTION' , '%s is required' , TypeError ) ;
1231
+ E ( 'ERR_MODULE_NOT_FOUND' , ( path , base , type = 'package' ) => {
1232
+ return `Cannot find ${ type } '${ path } ' imported from ${ base } ` ;
1233
+ } , Error ) ;
1210
1234
E ( 'ERR_MULTIPLE_CALLBACK' , 'Callback called multiple times' , Error ) ;
1211
1235
E ( 'ERR_NAPI_CONS_FUNCTION' , 'Constructor must be a function' , TypeError ) ;
1212
1236
E ( 'ERR_NAPI_INVALID_DATAVIEW_ARGS' ,
@@ -1241,12 +1265,15 @@ E('ERR_OUT_OF_RANGE',
1241
1265
msg += ` It must be ${ range } . Received ${ received } ` ;
1242
1266
return msg ;
1243
1267
} , RangeError ) ;
1244
- E ( 'ERR_PACKAGE_PATH_NOT_EXPORTED' , ( pkgPath , subpath ) => {
1268
+ E ( 'ERR_PACKAGE_PATH_NOT_EXPORTED' , ( pkgPath , subpath , base = undefined ) => {
1245
1269
if ( subpath === '.' ) {
1246
1270
return `No "exports" main resolved in ${ pkgPath } ${ sep } package.json` ;
1247
- } else {
1271
+ } else if ( base === undefined ) {
1248
1272
return `Package subpath '${ subpath } ' is not defined by "exports" in ${
1249
1273
pkgPath } ${ sep } package.json`;
1274
+ } else {
1275
+ return `Package subpath '${ subpath } ' is not defined by "exports" in ${
1276
+ pkgPath } imported from ${ base } `;
1250
1277
}
1251
1278
} , Error ) ;
1252
1279
E ( 'ERR_REQUIRE_ESM' ,
0 commit comments