为什么http模块不在node_modules文件夹中?

sab*_*bir 4 node.js

我的问题是 module 和 node.js 中的其他模块有什么区别http。为什么该http模块不位于./node_modules?我在哪里可以找到该模块?

Joe*_*icz 6

http模块由您安装的 Node.js 提供。这就是所谓的核心模块

您可以在存储库中查看它们的源代码(或在本地下载它们): https: //github.com/nodejs/node/tree/master/lib

更新

从 Node 18 开始,您可以通过在核心模块前面加上 前缀来引用它们node:,这可确保您不会加载共享相同名称的依赖项。

const http = require('node:http');
Run Code Online (Sandbox Code Playgroud)