Reputation: 836
When I print any module's module
object to the console, I get output such as the following:
{ id: '.',
exports: {},
parent: null,
filename: '/Users/myname/audiooutput/bin/audiomodule.js',
loaded: false,
children: [...], // array of module objects, omitted for brevity
paths: // what is this?
[ '/Users/myname/audiooutput/bin/node_modules',
'/Users/myname/audiooutput/node_modules',
'/Users/myname/node_modules',
'/Users/node_modules',
'/node_modules' ] }
Here I see the usual module
properties listed in the Node.js Documentation: id
, exports
, parent
, filename
, loaded
, and children
.
However, there is a final property, paths
, an array. The elements of the array don't refer to actual directories. They seem meaningless. So, my question is: what is the purpose/use of the paths property of module
objects, and why isn't it listed int the Node.js Documentation? Thanks.
Upvotes: 0
Views: 34
Reputation: 9025
It's the paths where require
will look for the modules you require from this file:
http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders.
Upvotes: 2