Node.js 查漏补缺(To be continued...)
作者:
那一瞬的光和永远 | 来源:发表于
2018-11-09 14:43 被阅读0次
1. 不熟的知识点
命令行
npm --help
npm init
npm ls
npm run
npm install --save-dev --verbose
- 查看进程:
lsof -i :7000
- 命令行打印响应:
curl -i localhost:7000
模块
- require 的查找顺序:核心模块 -> node_modules -> 当前目录向上
- require 一个文件,会通过 .js > .json > node 的形式去找
- require 一个文件夹,会去找文件夹下的 package.json 的 main,主程序入口
- fs 读写文件
- fs.readFile 的路径相对的是 node.js 的启动目录
(process.cwd() current work directory)
2. node.js debug
首先配置
"scripts": {
"start": "node --inspect index.js"
},
旧版本
chrome://flags
#enable-devtools-experiments
- 控制台——settings——experiments
- shift 6 次
- node debugging
新版本
chrome://inspect
- inspect
3. 构建工具
- 自动编译:
sudo npm install nodemon --save --verbose
本文标题:Node.js 查漏补缺(To be continued...)
本文链接:https://www.haomeiwen.com/subject/yltnxqtx.html
网友评论