Node.js 提供了许多内置的核心模块,其中有一些被称为工具模块,用于处理不同的任务。以下是一些常用的 Node.js 工具模块:

1. util 模块: 提供了一些实用函数,用于继承、检查对象类型等。
   const util = require('util');

2. events 模块: 用于处理事件的模块,包括 EventEmitter 类。
   const EventEmitter = require('events');

3. fs 模块: 用于文件系统操作,包括文件读写、目录操作等。
   const fs = require('fs');

4. path 模块: 用于处理文件路径的模块,包括路径拼接、解析等。
   const path = require('path');

5. http 模块: 用于创建 HTTP 服务器和客户端的模块。
   const http = require('http');

6. https 模块: 用于创建 HTTPS 服务器和客户端的模块。
   const https = require('https');

7. querystring 模块: 用于解析和格式化 URL 查询字符串。
   const querystring = require('querystring');

8. crypto 模块: 提供加密功能的模块,包括哈希、HMAC、加密、解密等。
   const crypto = require('crypto');

这些模块都是 Node.js 内置的模块,无需额外安装。你可以通过 require 来引入它们,然后利用它们提供的功能来完成相应的任务。


转载请注明出处:http://www.pingtaimeng.com/article/detail/13168/Node.js