Skip to content

Commit

Permalink
errors: simplify ERR_REQUIRE_ESM message generation
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Trott authored and MylesBorins committed Nov 16, 2020
1 parent 5405e62 commit 548137f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ E('ERR_REQUIRE_ESM',
filename : path.basename(filename);
msg +=
'\nrequire() of ES modules is not supported.\nrequire() of ' +
`${filename} ${parentPath ? `from ${parentPath} ` : ''}` +
`${filename} from ${parentPath} ` +
'is an ES module file as it is a .js file whose nearest parent ' +
'package.json contains "type": "module" which defines all .js ' +
'files in that package scope as ES modules.\nInstead rename ' +
Expand Down

0 comments on commit 548137f

Please sign in to comment.