当前位置:网站首页>今天的码农女孩总结了关于npm包管理和url模块的笔记
今天的码农女孩总结了关于npm包管理和url模块的笔记
2022-07-17 00:06:00 【丁丁丁dingdingding】
npm包管理:
以前我们引入第三方框架是用script标签引入js文件,现在在node环境下需要远程下载模块文件,所有在项目需要对模块进行记录和使用
创建步骤:
1.创建一个node文件夹
2.打开命令行工具,输入npm init进行初始化项目
package name: (nodeweb)项目名称,如果项目名称和文件不一致,则用项目名称启动
version: (1.0.0) 项目版本
description: 项目描述
entry point: (index.js) 项目程序入口
test command: 设置测试命令
git repository: 设置git仓库地址
keywords: 设置搜索关键字
author: ding 设置作者
license: (ISC) 设置服务器关键字
3.项目创建成功后,会在项目里自动生成package.json文件,记录了项目信息和模块信息
4.当你安装或卸载第三方模块,package.json文件会动态进行添加或删除操作
5.执行node下的文件
例如:node index.js
url模块
req.url获得的是相对路径,但是url模块用于解析url字符和对象,用于网络地址的方式操作
get的提交方式
http.createServer(function(req,res){
console.log(req.url)
console.log(url.parse(req.url))
let {pathname,href}=url.parse(req.url)
console.log(pathname)
console.log(href)
}).listen(8082)
post的提交方式
引入querystring模块,用来解析http请求的数据,进行拆分
http.createServer(function(req,res){
var arr=[]
req.on("data",buffer=>{//读取数据中
//当数据较大会分段读取,每次请求一部分字节
arr.push(buffer)
})
req.on("end",()=>{
var data=Buffer.concat(arr).toString()
console.log(data)
var obj=querystring.parse(data)
console.log(obj.name)
})
}).listen(8082)
边栏推荐
- Oracle automatic storage management 18C step-by-step installation -2
- js字符串转对象 js对象转字符串 js字符串与对象互转
- MoveIt2——5.场景规划
- Day13 mixed view base class
- ModelArts-人声检测and文本分类
- C Programming Language(2nd Edition)--读书笔记--1.5
- Cve-2022-34265 Django extract & TRUNC SQL injection vulnerability recurrence
- Day11 serializer
- 1. Internet foundation
- 鼠标右键菜单添加快速打开选项遇见的错误:
猜你喜欢

mock平台的使用说明
![Eye of depth III - (3)] mathematics: matrix eigenvalue and eigenvector 1](/img/81/7ad44da70eaf1d92b126c567766577.png)
Eye of depth III - (3)] mathematics: matrix eigenvalue and eigenvector 1

Day12 Association serialization processing

自己封装的风格化的开关卡片组件

Record once easy_ SQL Stack Injection
![Eye of depth III - (4, 5)] mathematics: matrix eigenvalues and eigenvectors 2](/img/fc/7a4bffc642d82fcfaf3be80bcc39fc.png)
Eye of depth III - (4, 5)] mathematics: matrix eigenvalues and eigenvectors 2

object-fit:cover;在小程序中不起作用,小程序图片变形了如何处理

Use bat to automatically execute CMD commands (multiple commands or a single command)

JS string to object JS object to string JS string to object

js字符串转对象 js对象转字符串 js字符串与对象互转
随机推荐
Oracle database startup and shutdown steps
uni 阻止按钮多次点击 按钮多次点击
uni-app微信小程序——商城(7)——商品详情
NodeJS 跨域 CORS
深度之眼三——(7,8)】数学:矩阵对角化及二次型2.3
Record once easy_ SQL Stack Injection
Fundamentals of IOT development
es6 map提取数组对象
Summary of XML external entity injection (xxE target recurrence)
Day10 front back continuous adjustment
[GFCTF 2021]Baby_ Cve-2021-41773 on the web
C Programming Language(2nd Edition)--读书笔记--1.5.1
Collection and summary of penetration test information
js截取字符串前几位或者截取字符串后几位
微信推送-模版消息参数配置
深度之眼三——(3)】 數學:矩陣特征值與特征向量1
自己封装的风格化的开关卡片组件
Use bat to automatically execute CMD commands (multiple commands or a single command)
STM32F10x--C语言-1
Oracle database parameter change