惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Last Watchdog
The Last Watchdog
博客园_首页
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
美团技术团队
小众软件
小众软件
V
V2EX
博客园 - Franky
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
Attack and Defense Labs
Attack and Defense Labs
S
Security Affairs
Simon Willison's Weblog
Simon Willison's Weblog
I
Intezer
T
The Exploit Database - CXSecurity.com
有赞技术团队
有赞技术团队
S
Schneier on Security
人人都是产品经理
人人都是产品经理
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
Kaspersky official blog
PCI Perspectives
PCI Perspectives
AI
AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
O
OpenAI News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Register - Security
The Register - Security
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
博客园 - 【当耐特】
C
Cisco Blogs
大猫的无限游戏
大猫的无限游戏
Help Net Security
Help Net Security
Google DeepMind News
Google DeepMind News
S
Securelist
Application and Cybersecurity Blog
Application and Cybersecurity Blog
P
Proofpoint News Feed
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
L
LangChain Blog
SecWiki News
SecWiki News
博客园 - 叶小钗
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V2EX - 技术
V2EX - 技术
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
J
Java Code Geeks
L
LINUX DO - 热门话题
Cisco Talos Blog
Cisco Talos Blog

博客园 - think8848

[原]使用BPI-R4开发板实现5G上网、Wi-Fi AP、文件共享和Docker服务 [原]挂载oVirt虚拟机磁盘 mongocxx-driver编译安装 Mapnik 3.0.20编译安装 [原]Webpack 3 + AngularJS1.* + Bootstrap 4 + Mapbox-gl VSCode下调试mocha测试用例 Mapbox Studio Classic 闪退问题解决方案 EventEmitter事件处理器中的this问题 Rappid 消除试用版的弹出框 CentOS7.2 1511部署RabbitMQ shp2pgsql向postgresql导入shape数据 node.js的Promise库-bluebird示例 [原]Docker部署SuperMap8.1.1 Docker初步 [原]OpenStreetMap数据瓦片服务性能篇 [原]CentOS7.2部署KVM虚拟机 [原]使用node-mapnik和openstreetmap数据初步搭建瓦片服务 [原]使用node-mapnik生成openstreetmap-carto风格的瓦片 [原]CentOS7.2部署node-mapnik
node.js 调试问题
think8848 · 2017-02-08 · via 博客园 - think8848

最近打算在项目过程中使用node.js辅助解决一些问题,需要用到node.js的调试技术。

通常而言,大家都会提到debugger或者node-inspector方法。

debugger方法谁用谁知道,一般应该没有人去使用,

node-inspector呢,如果你运气好,可能在两步之内就可以使用chrome来调试了,但是如果运气不好可能就看到

"Remote debugging has been terminated with reason: websocket_closed"错误

如果出现这个错误,很可能是你的node.js版本比较高的原因,你可以尝试将版本除到6.3以下,或者,修改下面中的文件(Linux下自已去找相应的文件路径)

将下图中红框中的代码注释掉

如果不介意使用最新版本的node.js(当前最新是7.5),那么就可以使用另一种选择

文档

即在启动node.js程序时使用如下命令

node --inspect=<ipaddress>:<port> --debug-brk index.js

然后在chrome浏览器中使用

chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=<ipaddress>:<port>/edf01bcd-4217-452a-b6ed-a24272862700

即可调试了。如果你觉得在chrome中每次输入这个麻烦,那么也可以安装一个chrom插件,然后使用相应的IP直接进入。

 效果(请忽略被调试的代码)

 -------------------------2017年2月12日更新 -------------------------

每次都要输入调试目标机器IP感觉很不爽,在Inspector的选项中可以进行配置,每次默认打开调试目标机器的地址。

进入后调上IP地址,打上两个勾。然后在调试目标机器 node --inspect=192.168.1.139:9229 --debug-brk app.js ,Chrome就会自动开启调试页面了,简直和VS一样方便!

 -------------------------2017年2月12日更新结束 -------------------------