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 86644b9

Browse filesBrowse files
benmccannruyadorno
authored andcommitted
doc: clarify that import also uses main
PR-URL: #41720 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 4889a31 commit 86644b9
Copy full SHA for 86644b9

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+8
-6
lines changed
Open diff view settings
Collapse file

‎doc/api/packages.md‎

Copy file name to clipboardExpand all lines: doc/api/packages.md
+8-6Lines changed: 8 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1093,17 +1093,19 @@ added: v0.4.0
10931093
}
10941094
```
10951095

1096-
The `"main"` field defines the script that is used when the [package directory
1097-
is loaded via `require()`](modules.md#folders-as-modules). Its value
1098-
is a path.
1096+
The `"main"` field defines the entry point of a package when imported by name
1097+
via a `node_modules` lookup. Its value is a path.
1098+
1099+
When a package has an [`"exports"`][] field, this will take precedence over the
1100+
`"main"` field when importing the package by name.
1101+
1102+
It also defines the script that is used when the [package directory is loaded
1103+
via `require()`](modules.md#folders-as-modules).
10991104

11001105
```cjs
11011106
require('./path/to/directory'); // This resolves to ./path/to/directory/main.js.
11021107
```
11031108

1104-
When a package has an [`"exports"`][] field, this will take precedence over the
1105-
`"main"` field when importing the package by name.
1106-
11071109
### `"packageManager"`
11081110

11091111
<!-- YAML

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.