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 4bde865

Browse filesBrowse 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 <anna@addaleax.net> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com>
1 parent f4e714a commit 4bde865
Copy full SHA for 4bde865

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
@@ -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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.