- Building Enterprise JavaScript Applications
- Daniel Li
- 202字
- 2021-07-23 16:31:21
Using ndb
On July 22, 2018, Google released ndb (https://github.com/GoogleChromeLabs/ndb), an "improved" debugger that is based on Chrome DevTools, and uses Puppeteer (github.com/GoogleChrome/puppeteer) to interact with Chromium over the DevTools Protocol. It requires at least Node.js v8.0.0.
You can try it out by installing it locally:
$ yarn add ndb --dev
On Windows, you may also have to install the windows-build-tools package in order to compile native dependencies:
$ yarn global add windows-build-tools
Then, you can run the ndb binary with npx, and a new window will pop up:
ndb comes with its own integrated terminal, which will hook onto any node processes that you run from it.
While using Chrome DevTools and/or ndb provides several unique benefits, such as the availability of the Console, Memory, and Profile tabs, I'd still recommend using the debugger that comes with your IDE or code editor, simply because there's less context switching that comes with switching between different tools.
I recommend using Visual Studio Code as a code editor for JavaScript projects, and thus we will use the VSCode editor to illustrate our workflow; you are, however, free to use the IDE or editor of your choice.