Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 548137f

Browse filesBrowse files
TrottMylesBorins
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 <anna@addaleax.net> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
1 parent 5405e62 commit 548137f
Copy full SHA for 548137f

File tree

Expand file treeCollapse file tree

1 file changed

+1
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+1
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/errors.js‎

Copy file name to clipboardExpand all lines: lib/internal/errors.js
+1-1Lines changed: 1 addition & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.