@@ -1104,18 +1104,28 @@ E('ERR_INVALID_PACKAGE_CONFIG', (path, message, hasMessage = true) => {
1104
1104
} , Error ) ;
1105
1105
E ( 'ERR_INVALID_PACKAGE_TARGET' ,
1106
1106
( pkgPath , key , subpath , target , base = undefined ) => {
1107
+ const relError = typeof target === 'string'
1108
+ && target . length && ! target . startsWith ( './' ) ;
1107
1109
if ( key === null ) {
1108
1110
if ( subpath !== '' ) {
1109
1111
return `Invalid "exports" target ${ JSONStringify ( target ) } defined ` +
1110
1112
`for '${ subpath } ' in the package config ${ pkgPath } imported from ` +
1111
- base ;
1113
+ ` ${ base } . ${ relError ? ' - targets must start with "./"' : '' } ` ;
1112
1114
} else {
1113
1115
return `Invalid "exports" main target ${ target } defined in the ` +
1114
- `package config ${ pkgPath } imported from ${ base } .` ;
1116
+ `package config ${ pkgPath } imported from ${ base } .${ relError ?
1117
+ ' - targets must start with "./"' : '' } `;
1115
1118
}
1116
1119
} else if ( key === '.' ) {
1117
1120
return `Invalid "exports" main target ${ JSONStringify ( target ) } defined ` +
1118
- `in the package config ${ pkgPath } ${ sep } package.json` ;
1121
+ `in the package config ${ pkgPath } ${ sep } package.json${ relError ?
1122
+ ' - targets must start with "./"' : '' } `;
1123
+ } else if ( typeof target === 'string' && target !== '' &&
1124
+ ! target . startsWith ( './' ) ) {
1125
+ return `Invalid "exports" target ${ JSONStringify ( target ) } defined for '${
1126
+ StringPrototypeSlice ( key , 0 , - subpath . length || key . length ) } ' in the ` +
1127
+ `package config ${ pkgPath } ${ sep } package.json. ` +
1128
+ '- targets must start with `./`' ;
1119
1129
} else {
1120
1130
return `Invalid "exports" target ${ JSONStringify ( target ) } defined for '${
1121
1131
StringPrototypeSlice ( key , 0 , - subpath . length || key . length ) } ' in the ` +
0 commit comments