node.js - 为什么 http 模块不在 node_modules 文件夹中?

标签 node.js

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

最佳答案

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

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

更新

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

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

关于node.js - 为什么 http 模块不在 node_modules 文件夹中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55311493/

相关文章:

node.js - MongoDb类型错误: Cannot read property 'insertMany' of undefined

javascript - 如果显式定义排序顺序,排序会非常慢

node.js - google talk中的用户授权与nodejs和node-xmpp

node.js - 将node js查询结果分离成对象?

node.js - 如果特定公会不存在,则会出现数据库错误

javascript - Node.js 中的对象字面量会阻塞吗

node.js - 意外的 token 非法 - response.write() 错误

node.js - 如何在 Heroku/Node.js 上部署 Rserve

javascript - jade 调节给 var 一个默认值

javascript - 在 NodeJs 端点中引用 JSON 对象时未定义“id”