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 f70c71f

Browse filesBrowse files
drywolfjasnell
authored andcommitted
doc: explain error message on missing main file
Added a hint saying that node uses the default "Cannot find module" error when requiring a module for which the "main" file specified in the package.json is missing. PR-URL: #5812 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 91cf55b commit f70c71f
Copy full SHA for f70c71f

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

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

‎doc/api/modules.markdown‎

Copy file name to clipboardExpand all lines: doc/api/modules.markdown
+8Lines changed: 8 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,14 @@ If this was in a folder at `./some-library`, then
346346

347347
This is the extent of Node.js's awareness of package.json files.
348348

349+
Note: If the file specified by the `"main"` entry of `package.json` is missing
350+
and can not be resolved, Node.js will report the entire module as missing with
351+
the default error:
352+
353+
```
354+
Error: Cannot find module 'some-library'
355+
```
356+
349357
If there is no package.json file present in the directory, then Node.js
350358
will attempt to load an `index.js` or `index.node` file out of that
351359
directory. For example, if there was no package.json file in the above

0 commit comments

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