Skip to content

Commit 4bde865

Browse files
Trottruyadorno
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: #35123 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Guy Bedford <[email protected]>
1 parent f4e714a commit 4bde865

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
@@ -1303,7 +1303,7 @@ E('ERR_REQUIRE_ESM',
13031303
filename : path.basename(filename);
13041304
msg +=
13051305
'\nrequire() of ES modules is not supported.\nrequire() of ' +
1306-
`${filename} ${parentPath ? `from ${parentPath} ` : ''}` +
1306+
`${filename} from ${parentPath} ` +
13071307
'is an ES module file as it is a .js file whose nearest parent ' +
13081308
'package.json contains "type": "module" which defines all .js ' +
13091309
'files in that package scope as ES modules.\nInstead rename ' +

0 commit comments

Comments
 (0)