Home > Enterprise >  Location of NodeJS standard library
Location of NodeJS standard library

Time:12-17

Can someone please help me find the location of standard NodeJS modules like http or fs?

When I write:

const http = require('http');

Where is the module coming from? For NPM this is easy to find, but strangely I can't find http.js or any other standard library file.

CodePudding user response:

Well it depends of which system you are, If you are on windows it's in C:\Program Files\nodejs\node_modules\npm\node_modules or at least I think... If you want to know on linux check out [this question][1] on the askubuntu.com website. In this question, someone answered that it was in

/usr/local/lib/node or /usr/local/lib/node_modules

  • Tejas Lotlikar

There is a high chance that on mac, the location is the same as linux because macOS is based upon some "ancient" linux dist. [1]: https://askubuntu.com/questions/1189230/what-is-the-location-of-node-modules

CodePudding user response:

The actual running node location can be found with this command

node -e "console.log(process.execPath)"

this will output the executed bin compiled nodejs path. which will not really much help you.

what will help you is knowing the node version you are running and check the source code of the module you want. http.js .

or debug nodejs in real time. break point on the http module and then get into the module itself with the help of the debugger. check out this guide

  • Related