Skip to content

Commit 548137f

Browse files
TrottMylesBorins
authored andcommittedNov 16, 2020
errors: simplify ERR_REQUIRE_ESM message generation
Because of the condition that starts the `if` block, we know that `parentPath` must be truthy. So there is no need to check for that in the template string that generates the error message. PR-URL: #35123 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
1 parent 5405e62 commit 548137f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎lib/internal/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ E('ERR_REQUIRE_ESM',
12961296
filename : path.basename(filename);
12971297
msg +=
12981298
'\nrequire() of ES modules is not supported.\nrequire() of ' +
1299-
`${filename} ${parentPath ? `from ${parentPath} ` : ''}` +
1299+
`${filename} from ${parentPath} ` +
13001300
'is an ES module file as it is a .js file whose nearest parent ' +
13011301
'package.json contains "type": "module" which defines all .js ' +
13021302
'files in that package scope as ES modules.\nInstead rename ' +

0 commit comments

Comments
 (0)
Please sign in to comment.