Skip to content

Commit f6a9120

Browse files
Trottjoesepi
authored andcommitted
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: nodejs#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 6d819bb commit f6a9120

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

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)