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