Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node core modules location

Tags:

node.js

fs

After installation of nodejs where can I find the core modules themselves? What is the path to them on my Linux machine? For example I want to see where is the fs module.

like image 983
Nataly Avatar asked Mar 19 '17 19:03

Nataly


People also ask

Where are node modules located?

On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally. If you set the NODE_PATH environment variable to this path, the modules can be found by node. Non-global libraries are installed the node_modules sub folder in the folder you are currently in.

What is node_modules .bin folder?

The directory node_modules/.bin is where the binaries of the modules used by your project are stored, normally using symbolic links to the respective binaries in the corresponding module's directory.


1 Answers

They are compiled into the executable, but their source can be found here.

EDIT: I'm not intimately familiar with Node's building process, but from what I understand (mostly from this) is that all files in the abovementioned directory are "converted" to C++ using tools/js2c.py and the results are written to an intermediate file node_javascript.cc during the building process.

I assume that they hook somewhere into the module/bindings system of Node so that when you use, for instance, require('fs'), Node will look in its internal list of modules first.

like image 180
robertklep Avatar answered Oct 18 '22 12:10

robertklep