doc: explain error message on missing main file
authorWolfgang Steiner <drywolf.dev@gmail.com>
Sun, 20 Mar 2016 18:29:36 +0000 (19:29 +0100)
committerMyles Borins <mborins@us.ibm.com>
Wed, 30 Mar 2016 20:12:16 +0000 (13:12 -0700)
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: https://github.com/nodejs/node/pull/5812
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
doc/api/modules.markdown

index 4c4cacb..20c8b17 100644 (file)
@@ -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