1 可以脱离浏览器来执行js代码,没有DOM和BOM对象,针对后端可以编写接口,提供网页资源,前端可以集成各种工具(承上启下)
node 1.Buffer
2.Buffer相关操作
1 2 3 4 5 6 let buf = Buffer .alloc (10 )console .log (buf);let buf_2 = Buffer .allocUnsafe (100 )console .log (buf_2);let buf_3 = Buffer .from ('hello' )console .log (buf_3);
3.fs模块-读写模块【回顾一下liunx操作系统】【增删改查操作】
4.fs异步和同步
5.fs文件追加操作
6.文件写入的场景-【做持久化】
7.文件读取
8.写一个创建文件的脚本 9.fs流式写入
10.exports对象 1 2 由于module.exports 单词写起来比较复杂,为了简化向外共享成员的代码,Node 提供了exports 对象。默认情况下,exports和module.exports 指向同一个对象。最终共享的结果,还是以module.exports指向的对象为准。 时刻谨记,require()模块时,得到的永远是module.exports指向的对象:
11.计算机组成
12.模块化 1 2 3 4 5 -require的使用 -模块化的好处->无法共享成员 -module对象,每个.js都自定义模块中都有一个module对象 -exports 自定义模块中,可以使用exports将模块中的成员共享出去,给外界使用 在自定义模块中,默认情况下,module.export = {} 使用require()方法导入模块时,导入的结果,永远以module.exports指向的对象为准。
13.模块化初体验
14.模块暴露数据
15.导入(引入)模块 导入 js 和 json文件时 可以省略后缀
16.导入模块的基本流程
17.commonJS规范
18.包管理工具【哆啦A梦】
19.npm
20.npm基本使用 20.1初始化
1 2 3 4 5 6 7 8 9 10 11 12 { "name" : "test01" , "version" : "1.0.0" , "description" : "" , "main" : "index.js" , "scripts" : { "test" : "echo \"Error: no test specified\" && exit 1" }, "author" : "c" , "license" : "ISC" }
20.3require导入包的基本流程
20.4开发依赖和生产依赖 https://juejin.cn/post/7135795969370619918
20.5npm全局安装
20.6修改windows执行策略
21.环境变量path
20.1 npm安装包的所有依赖
22.安装指定版本的包
23.配置命令别名
24.cnpm
25.配置淘宝镜像
26.yarn
27.npm和yarn的使用
28.管理发布包
29.更新和删除
30.扩展
31.nvm
32.常用命令
33.expressJS Express是一个流行的Node.js Web应用程序框架,用于构建服务器端应用程序。它提供了一组简洁而灵活的工具和中间件,使开发者可以轻松地构建RESTful API和Web应用。Express具有路由、请求和响应处理、中间件等功能,可以帮助开发者管理HTTP请求和构建服务器端逻辑。通过Express,可以搭建一个响应请求的服务器,处理前端发起的HTTP请求并返回相应的数据或页面。
34.简单应用 35.路由
方法
路径
回调1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 const express = require ('express' )const app = express ()app.get ('/home' ,(req,res ) => { res.end ('Welcome to the Home page' ) } ) app.get ('/' ,(req,res ) => { res.end ('Welcome to the Home page with instructions for creating' ) }) app.post ('/login' ,(req,res ) => { res.end ('Welcome to the Login page' ) }) app.get ('*' ,(req,res ) => { res.end ('404 Not Found ' ) }) app.listen (3000 ,()=> { console .log ('listening on http://localhost' ) })
36.获取请求参数
37.获取路由参数