sabbir
sabbir

Reputation: 125

Why http module is not located in the node_modules folder?

My question is what is the difference between http module and other modules in node.js . why is the http module not located in ./node_modules? Where I can find the module?

Upvotes: 4

Views: 628

Answers (2)

Joey Ciechanowicz
Joey Ciechanowicz

Reputation: 3663

The http module is provided by your installation of Node.js. It's what's known as a core module

You can view the source to them in the repo (or download them locally): https://github.com/nodejs/node/tree/master/lib

Update

As of Node 18 you can reference core modules by prefixing them with node:, which ensures you don't load a dependency that shares the same name.

const http = require('node:http');

Upvotes: 6

Nikheel Dangariya
Nikheel Dangariya

Reputation: 51

  • HTTP modules are compiled into its binary distribution and load automatically when Node.js process starts. but, you need to import the core module first in order to use it in your application.
  • var http = require('http');

Upvotes: 2

Related Questions