目录
命令
vmware虚拟机配置
配置虚拟机IP地址 ifconfig
ls /etc/sysconfig/network-scripts/
vi /etc/sysconfig/network-scripts/ifcfg-ens32
systemctl restart network.service
怎么推出送到bitbucket库
git config --global user.name "yangziyi"
git config --global user.email "771400831@qq.com"
git config --list(查看配置信息)
(第一次需要配置)
cp -r ../nodejs-demo/ * .
git add .
git status
git commit -m "third lesson"
git push
eslint生成配置文件
~/nodejs-demo eslint --init
How would you like to configure ESLint? Answer questions about your style
Are you using ECMAScript 6 features? Yes
Are you using Es6 modules? No
where will your code run? Browser, NodeDo you use CommonJS? No
Doyou use JsX? No
what style of indentation do you use? Spaceswhat quotes do you use for strings? singlewhat line endings do you use? Unix
Doyou require semicolons? Yes
what format do you want your config file to be in? JSON
successfully created .eslintrc.json file in /home/wangding/nodejs-demo
====================================
dependencies,项目依赖
devDependencies,开发依赖
文件系统操作对象
1.文件
2.目录
3.链接
4.属性
权限(mode) rw -r-x rwx
文件所有者权限 u 所属的组的权限g 其他人的权限o
read 100=>4
write 010=>2
excute 001=>1
添加执行权限 chmod u+x a.js
chmod 777 a.js
lrd => live reload热加载
实现的两个技术点:watching files
server=>client(客户端) 利用websocket
语法错误、逻辑错误、运行时错误
编译语言:
编译型 hello.c => hello.o =>hello.exe
解释型 javascript a.js
两种调试手段:
1.交互调试 不适合异步代码
2.打印调试 最重要、最简单
交互调试的技术点
1.控制语句执行(单步执行、断点、条件断点、跳入、跳出)
2.查看某些变量
交互调试的方法:linux只能控制台界面
1.控制台界面 node inspect a.js
next(n) step(s) out(o) setBreakpoint(sb) repl查看变量 list打印代码
2.图形用户界面
事件管理
emitter.on('event-name',callback);
on = addEventListener
订阅事件0r监听事件
触发事件 emit('event-name',...arg)
同步下的异常 try catch
异步下的异常 全局异常捕获:
process.on('uncaughtException',(err)=>{
console.log(err.message);
process.exit(1);
})
标准流
stdin stdout stderr
命令行操作和API是相反的
stdin是可读流
stream是EventEmitter和Buffer的组合
.pipe只能用在可读流
一个可写流必须调用一个end()方法,write可以多个或者没有
同步API适合操作小文件
异步API适合操作大文件
配置文件 同步
空目录的字节是6,空文件的字节是0
rmdirSync()不能删除非空目录
rmSync()删除文件
renameSync()既能改文件,也能改目录 相当于mv
链接分类
1.符号链接(软链接)symbol link ink(快捷方式)->link 指向问题
2.硬链接 hard link(副本)
作用:符号链接指向关系删掉之后就会失效报错
硬链接每个链接是原始文件的副本,删掉哪一个无影响
ln -s file1 file2 符号链接 file2->file1
ln file1 file2 硬链接
静态代码检查ESLint
1.发现语法错误
2.实现编码规范
npm i -g eslint
eslint --init
esint .
mian.js->dog.js
NODE_DEBUG=app dog node main.js相当于curl
如何改正错误:语法没错修改json
子进程
child process vs process
thread vs process
都可以利用CPUs计算能力
启动外部程序
cat,sort uniq..
API ABI:Application Binary Interface 二进制
reuse重用
DRY:don't repeat yourself
cat > a.txt 这个>就是重定向 shell外壳