node.js基本操作:
查看路径
PS C:\Users\hao_z\Desktop\php> pwd
Path
----
C:\Users\hao_z\Desktop\php
查看版本
PS C:\Users\hao_z\Desktop\php>node -v
v16.13.0
切换目录
PS C:\Users\hao_z\Desktop\php> cd 0403
运行文件 .js后缀可省略
PS C:\Users\hao_z\Desktop\php\0403> node demo.js
hello world
设置第三方模块国内镜像
PS C:\Users\hao_z\Desktop\php\0403> npm config set registry https://registry.npm.taobao.org
建立包仓库:y为yes,默认选择,否则逐项配置
PS C:\Users\hao_z\Desktop\php\0403>npm init -y
装置第三方包,install简写为i
PS C:\Users\hao_z\Desktop\php\0403> npm i lodash
added 1 package in 2s
卸载第三方包:uni
PS C:\Users\hao_z\Desktop\php\0403> npm uni lodash
removed 1 package, and audited 1 package in 711ms
found 0 vulnerabilities
更新node.js版本
PS C:\Users\hao_z\Desktop\php\0403> npm i npm-check-updates -g
npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs
added 317 packages in 12s
查看全局包目录,g:global
PS C:\Users\hao_z\Desktop\php\0403> npm root -g
C:\Users\hao_z\AppData\Roaming\npm\node_modules
全局安装
PS C:\Users\hao_z\Desktop\php\0403> npm i lodash -g
added 1 package in 2s
全局卸载,全局包必须全局卸载
PS C:\Users\hao_z\Desktop\php\0403> npm uni lodash -g
removed 1 package, and audited 1 package in 804ms
found 0 vulnerabilities
查看包仓库
PS C:\Users\hao_z\Desktop\php\0403> npm list
0403@ C:\Users\hao_z\Desktop\php\0403
└── lodash@4.17.21
查看全局包
PS C:\Users\hao_z\Desktop\php\0403> npm list -g
C:\Users\hao_z\AppData\Roaming\npm
├── express-generator@4.16.1
├── mkdirp@1.0.4
└── npm-check-updates@16.10.0
安装生产依赖-S/开发依赖-D
PS C:\Users\hao_z\Desktop\php\0403> npm i jquery -D
added 1 package in 1s
总结:
fetch api前端应该会常用;node听说过,没用过,前面讲的模块不错,想用模块应该需要用node。