Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
drywolf committed Mar 21, 2016
commit ba95e028f8a57e9213775e3a4dc68956496a2403
8 changes: 8 additions & 0 deletions doc/api/modules.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ If this was in a folder at `./some-library`, then

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

Note: If the file specified by the `"main"` entry of `package.json` is missing
and can not be resolved, Node.js will report the entire module as missing with
the default error:

```
Error: Cannot find module 'some-library'
```

If there is no package.json file present in the directory, then Node.js
will attempt to load an `index.js` or `index.node` file out of that
directory. For example, if there was no package.json file in the above
Expand Down