node模块化

模块化
- 系统模块
- 自定义模块
- 包管理器

系统模块:
1.crypto 加密
2 Event 事件
3 File System
4.net 邮件等 网络操作
5 os 系统操作
6 path 路径
7 stream 流操作
8 timer 定时器
9 zlib 压缩
断言:只要不是这样,就死掉了

自定义模块
- 1 模块组成
- require 请求 引入模块

const mod1= require('./mod.js) //引入自己模块需要有./
console.log(mod1)

- module 模块
- exports 输出

exports.a = 12 //单个
module.exports = {} //多个

- 2 npm
- 3 发布

猜你喜欢

转载自blog.csdn.net/aruking/article/details/80104514