Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
调试
|
233
20.3
 使用
Node
的内建调试器
Node
有一个内建的调试器,让你可以一步步地运行一遍自己的应用,就好像骑着
JavaScript
解释器兜风一般。只需增加一个
inspect
参数,就可以开启对应用的调试:
node inspect meadowlark.js
执行之后,你立即就会注意到一些东西。首先,会在控制台上看到一个
URL
。这是因为这
个
Node
调试器需要创建一个自己的
We
b
服务器,这是它的工作方式。通过这个
Web
服
务器,就可以控制执行所要调试的应用了。
We
b
服务器的这一点也许还没有让你“眼前一
亮”,不过讨论到调试客户端的时候,它的用处就很清楚了。
当你进入了控制台调试器,就可以通过键入
help
来获得一个命令列表。这些命令当中你
用得最多的是
n
(下一语句)、
s
(步进)和
o
(步出)。
n
会单步执行当前代码行:它会执
行这行代码,但如果这行代码调用了其他函数,那么待这些函数执行完毕控制才会交回给
你。相对而言,
s
命令会进入当前代码行:如果这行代码调用了其他函数,你就能够进入
这些函数。
o
命令让你可以从当前正在执行的函数中跳出来。(要注意,“步进”和“步出”
仅仅是针对
函数
而言,它们并不会进入或跳出
if
和
for
代码块以及其他的控制流语句。)
这个命令行调试器还有更多的功能,但很有可能你并不想过多地使用它。虽然对很多事情
来说命令行非常好,但调试不在其中。虽然在紧要关头还有命令行可用也是个好事(例
如,如果只能通过
SSH
访问服务器
,或者服务器上没有安装图形用户界面),但更多的时
候,你会更愿意使用图形化的调试客户端。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099