Skip to content

Commit f54254a

Browse files
committed
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 <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Guy Bedford <[email protected]>
1 parent 91272bc commit f54254a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/internal/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ E('ERR_REQUIRE_ESM',
13171317
filename : path.basename(filename);
13181318
msg +=
13191319
'\nrequire() of ES modules is not supported.\nrequire() of ' +
1320-
`${filename} ${parentPath ? `from ${parentPath} ` : ''}` +
1320+
`${filename} from ${parentPath} ` +
13211321
'is an ES module file as it is a .js file whose nearest parent ' +
13221322
'package.json contains "type": "module" which defines all .js ' +
13231323
'files in that package scope as ES modules.\nInstead rename ' +

0 commit comments

Comments
 (0)