Node Module - Node_modules directory

1 - About

If the module identifier passed to require():

  • is not a core module
  • does not begin with '/', '../', or './',

then Node.js starts at the parent directory of the current module, and adds /node_modules, and attempts to load the module from that location.

If it is not found there, then it moves to the parent directory, and so on, until the root of the file system is reached.

3 - Example

For example, if the file at /home/ry/projects/foo.js called require('bar.js')'', then Node.js would look in the following locations, in this order:


/home/ry/projects/node_modules/bar.js
/home/ry/node_modules/bar.js
/home/node_modules/bar.js
/node_modules/bar.js

4 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap