@@ -774,13 +774,17 @@ E('ERR_INVALID_OPT_VALUE', (name, value) =>
774774 RangeError ) ;
775775E ( 'ERR_INVALID_OPT_VALUE_ENCODING' ,
776776 'The value "%s" is invalid for option "encoding"' , TypeError ) ;
777+ E ( 'ERR_INVALID_PACKAGE_CONFIG' ,
778+ 'Invalid package config in \'%s\' imported from %s' , Error ) ;
777779E ( 'ERR_INVALID_PERFORMANCE_MARK' ,
778780 'The "%s" performance mark has not been set' , Error ) ;
779781E ( 'ERR_INVALID_PROTOCOL' ,
780782 'Protocol "%s" not supported. Expected "%s"' ,
781783 TypeError ) ;
782784E ( 'ERR_INVALID_REPL_EVAL_CONFIG' ,
783785 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL' , TypeError ) ;
786+ E ( 'ERR_INVALID_REPL_TYPE' ,
787+ 'Cannot specify --type for REPL' , TypeError ) ;
784788E ( 'ERR_INVALID_RETURN_PROPERTY' , ( input , name , prop , value ) => {
785789 return `Expected a valid ${ input } to be returned for the "${ prop } " from the` +
786790 ` "${ name } " function but got ${ value } .` ;
@@ -811,6 +815,9 @@ E('ERR_INVALID_SYNC_FORK_INPUT',
811815 TypeError ) ;
812816E ( 'ERR_INVALID_THIS' , 'Value of "this" must be of type %s' , TypeError ) ;
813817E ( 'ERR_INVALID_TUPLE' , '%s must be an iterable %s tuple' , TypeError ) ;
818+ E ( 'ERR_INVALID_TYPE_FLAG' ,
819+ 'Type flag must be one of "module", "commonjs". Received --type=%s' ,
820+ TypeError ) ;
814821E ( 'ERR_INVALID_URI' , 'URI malformed' , URIError ) ;
815822E ( 'ERR_INVALID_URL' , 'Invalid URL: %s' , TypeError ) ;
816823E ( 'ERR_INVALID_URL_SCHEME' ,
@@ -865,13 +872,6 @@ E('ERR_MISSING_ARGS',
865872E ( 'ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK' ,
866873 'The ES Module loader may not return a format of \'dynamic\' when no ' +
867874 'dynamicInstantiate function was provided' , Error ) ;
868- E ( 'ERR_MODULE_NOT_FOUND' , ( module , base , legacyResolution ) => {
869- let msg = `Cannot find module '${ module } ' imported from ${ base } .` ;
870- if ( legacyResolution )
871- msg += ' Legacy behavior in require() would have found it at ' +
872- legacyResolution ;
873- return msg ;
874- } , Error ) ;
875875E ( 'ERR_MULTIPLE_CALLBACK' , 'Callback called multiple times' , Error ) ;
876876E ( 'ERR_NAPI_CONS_FUNCTION' , 'Constructor must be a function' , TypeError ) ;
877877E ( 'ERR_NAPI_INVALID_DATAVIEW_ARGS' ,
@@ -956,6 +956,20 @@ E('ERR_TRANSFORM_ALREADY_TRANSFORMING',
956956E ( 'ERR_TRANSFORM_WITH_LENGTH_0' ,
957957 'Calling transform done when writableState.length != 0' , Error ) ;
958958E ( 'ERR_TTY_INIT_FAILED' , 'TTY initialization failed' , SystemError ) ;
959+ E ( 'ERR_TYPE_MISMATCH' , ( filename , ext , typeFlag , conflict ) => {
960+ const typeString =
961+ typeFlag === 'module' ? '--type=module or -m' : '--type=commonjs' ;
962+ // --type mismatches file extension
963+ if ( conflict === 'extension' )
964+ return `Extension ${ ext } is not supported for ` +
965+ `${ typeString } loading ${ filename } ` ;
966+ // --type mismatches package.json "type"
967+ else if ( conflict === 'scope' )
968+ return `Cannot use ${ typeString } because nearest parent package.json ` +
969+ ( ( typeFlag === 'module' ) ?
970+ 'includes "type": "commonjs"' : 'includes "type": "module",' ) +
971+ ` which controls the type to use for ${ filename } ` ;
972+ } , TypeError ) ;
959973E ( 'ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET' ,
960974 '`process.setupUncaughtExceptionCapture()` was called while a capture ' +
961975 'callback was already active' ,
@@ -972,10 +986,8 @@ E('ERR_UNHANDLED_ERROR',
972986// This should probably be a `TypeError`.
973987E ( 'ERR_UNKNOWN_CREDENTIAL' , '%s identifier does not exist: %s' , Error ) ;
974988E ( 'ERR_UNKNOWN_ENCODING' , 'Unknown encoding: %s' , TypeError ) ;
975-
989+ E ( 'ERR_UNKNOWN_FILE_EXTENSION' , 'Unknown file extension: %s' , TypeError ) ;
976990// This should probably be a `TypeError`.
977- E ( 'ERR_UNKNOWN_FILE_EXTENSION' , 'Unknown file extension: \'%s\' imported ' +
978- 'from %s' , Error ) ;
979991E ( 'ERR_UNKNOWN_MODULE_FORMAT' , 'Unknown module format: %s' , RangeError ) ;
980992E ( 'ERR_UNKNOWN_SIGNAL' , 'Unknown signal: %s' , TypeError ) ;
981993
0 commit comments