File tree 1 file changed +9
-9
lines changed
1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -352,22 +352,22 @@ If this was in a folder at `./some-library`, then
352
352
353
353
This is the extent of Node.js's awareness of ` package.json ` files.
354
354
355
- If the file specified by the ` 'main' ` entry of ` package.json ` is missing and
356
- can not be resolved, Node.js will report the entire module as missing with the
357
- default error:
358
-
359
- ``` txt
360
- Error: Cannot find module 'some-library'
361
- ```
362
-
363
- If there is no ` package.json ` file present in the directory, then Node.js
355
+ If there is no ` package.json ` file present in the directory, or if the
356
+ ` 'main' ` entry is missing or cannot be resolved, then Node.js
364
357
will attempt to load an ` index.js ` or ` index.node ` file out of that
365
358
directory. For example, if there was no ` package.json ` file in the above
366
359
example, then ` require('./some-library') ` would attempt to load:
367
360
368
361
* ` ./some-library/index.js `
369
362
* ` ./some-library/index.node `
370
363
364
+ If these attempts fail, then Node.js will report the entire module as missing
365
+ with the default error:
366
+
367
+ ``` txt
368
+ Error: Cannot find module 'some-library'
369
+ ```
370
+
371
371
## Loading from ` node_modules ` Folders
372
372
373
373
<!-- type=misc-->
You can’t perform that action at this time.
0 commit comments