美文网首页
Node.js 查漏补缺(To be continued...)

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"
      },
    

    旧版本

    1. chrome://flags
    2. #enable-devtools-experiments
    3. 控制台——settings——experiments
    4. shift 6 次
    5. node debugging

    新版本

    1. chrome://inspect
    2. inspect

    3. 构建工具

    • 自动编译:sudo npm install nodemon --save --verbose

    相关文章

      网友评论

          本文标题:Node.js 查漏补缺(To be continued...)

          本文链接:https://www.haomeiwen.com/subject/yltnxqtx.html