开源库 | 地址 | 描述 | 备注 |
q | https://github.com/kriskowal/q |
| 参考:https://blog.csdn.net/ii1245712564/ 百度“nodejs q模块” |
request | https://github.com/request/request | 让node.js http请求变得超简单 | 百度:“node request” |
request-progress | request-progress - npm | 读取网络静态资源 | 读取网络静态资源,可以以流的方式存储本地 |
cookie-parser | https://github.com/expressjs/cookie-parser | express框架处理cookie | |
express-session | https://github.com/expressjs/session | express框架处理session | |
body-parser | https://github.com/expressjs/body-parser | express框架处理请求的body | |
node-base64-image | https://github.com/riyadhalnur/node-base64-image | Download images from remote URLs or use local images and encode/decode them to Base64 string or Buffer object | |
nodemon | https://github.com/remy/nodemon | node工程修改代码后自动重启 | |
redis | https://github.com/NodeRedis/node_redis | 缓存,将数据存储在内存中,减少数据库访问次数 | |
should | https://github.com/tj/should.js | 简单的单元测试库 | |
https://github.com/node-webot/wechat | 微信公共平台消息接口服务中间件 | ||
node-http-proxy | https://github.com/nodejitsu/node-http-proxy | node服务器设置代理 | express服务器内置设置代理的方法:Express behind proxies - Express 中文文档 | Express 中文网 |
event-stream | https://github.com/dominictarr/event-stream | node流处理 | Node.js Stream(流) | 菜鸟教程 |
connect-history-api-fallback | https://github.com/bripkens/connect-history-api-fallback | 服务器端通过插件使用HTML5 History API,对于单页应用处理路由很重要 | connect-history-api-fallback库的理解_astonishqft的博客-CSDN博客_connect-history-api-fallback |
node-htmlparser | https://github.com/tautologistics/node-htmlparser | 解析HTML文档 | 可防止XSS攻击 |
node-schedule | https://github.com/node-schedule/node-schedule | node定时任务 | |
cron | cron - npm | node定时任务 | |
pm2 | https://github.com/Unitech/pm2 | pm2 是一个带有负载均衡功能的Node应用的进程管理器 | pm2-logrotate(https://github.com/keymetrics/pm2-logrotate)日志切割 |
forever | https://github.com/foreverjs/forever | node守护进程 | |
easy-monitor | https://github.com/hyj1991/easy-monitor | 轻量级实时 Node.js 内核性能监控分析工具 | |
jschardet | jschardet - npm | 判断文件编码 | 判断文件编码是utf-8 / Big5等 |
csv | 解析csv的库 | 以csv-parser为例,如果出现编码问题需要引入iconv库,代码见附录1 | |
egg | egg - 为企业级框架和应用而生 | 企业级node框架 | 自带多线程,基于cluster模块 |
nest | Documentation | NestJS - A progressive Node.js framework | 企业级node框架 | 多线程应该需要依赖PM2(个人未测试) |
electronjs | Electron | Build cross-platform desktop apps with JavaScript, HTML, and CSS. | 使用 JavaScript, HTML 和 CSS 构建跨平台的桌面应用 | vscode就是基于这个框架开发的 |
commander | https://github.com/tj/commander.js/blob/HEAD/Readme_zh-CN.md | node.js 命令行接口的完整解决方案,灵感来自 Ruby 的 commander | |
puppeteer | https://github.com/puppeteer/puppeteer | 爬虫、自动化测试 | Puppeteer 是 Chrome 开发团队在 2017 年发布的一个 Node.js 包,用来模拟 Chrome 浏览器的运行。 |
cherrio | cheerio | node端的jQuery库 | |
gm | gm - npm | 图片工具GraphicsMagick的链接库 | 需要本地先安装GraphicsMagick,这个软件可以做到图片添加水印等,功能强大 |
sharp | sharp - npm | 压缩图片 | |
cross-env | cross-env - npm | 解决命令行传参跨平台问题 | windows下传参可能提示错误 |
config | config - npm | 为应用分环境提供配置文件 | |
husky | husky - npm | git钩子 | 保证git注释更规范 |
prettier | prettier - npm | 代码格式化工具 | |
npm-run-all | npm-run-all - npm | 运行多个npm命令 | A CLI tool to run multiple npm-scripts in parallel or sequential. |
systemjs | systemjs - npm | 动态引入文件资源,类似require.js | 参考single-spa文档的例子: single-spa | single-spa |
concurrently | concurrently - npm | package.json中运行多个命令 | 类似npm run watch-js & npm run watch-less ,但效果更好. |
socket.io | Socket.IO | socket通信 | 基于websocket协议的长链接库,支持nodejs、java、Python等 |
glob | glob - npm | glob命令的js实现 | 按规则(例如“src/**/**.entity.{ts,js}”)读取文件 |
npm-check-updates | npm-check-updates - npm | 更新 | 更新package.json中依赖到最新版本,除非指定的是固定版本 |
附录:
1、csv库的使用示例
import csv from 'csv-parser';
import { Iconv } from 'iconv';
import fs from 'fs';
const convertEncoding = new Iconv('GBK', 'UTF-8'); // GBK转UTF-8
const filePath = 'aa.csv'
fs.createReadStream(filePath)
.pipe(convertEncoding)
.pipe(csv())
.on('data', (data) => {
// 解析csv文件的内容,data为一行数据的json对象
if (!!data) {
// csv当前行数据解析出错,比如双引号使用不规范等
}
})
.on('end', () => {
// csv解析完毕
})
.on('error', () => {
// csv文件解析出错
});