Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

When we do some Node related development, we often output the content of variables to the Console through the Console for viewing. Simple data viewing is ok, but when we encounter large objects, attribute functions and other mounted many may not be displayed on the Console, or even the content is washed out. Today we’re going to use Node-nightly to make it easy to debug, view our objects, and output logs in Chrome.

Let’s take a look at the effect with a simple demo plugin for WebPack

Prepare the node – the nightly:

  1. Installation node – the nightly: npm install --global node-nightly.

  1. Perform the node – the nightly:node-nightly.

Startup entry script:

  1. throughnode-nightlyExecute entry script:node-nightly --inspect-brk ./node_modules/webpack/bin/webpack.js, the script breaks at the first statement and waits for action.
  2. The inputchrome://inspectOpen theChrome Inspect.
  3. To inspect:

  1. Script in wait state:

  1. Add the current Node project workspace to Source, and you can debug JavaScript as you would in Chrome.

The information in the Console is also printed

added

  1. Often our WebPack configuration files will differentiate between different environments for special configuration,node-nightlyIt also allows us to add configuration after executing a command such as:--config webpack.prod.js.
  2. Debugging our other simple Node single scripts will be much easier, so you can try them out.
  3. ifnode-nightlyIf it is abnormal at runtime, we can install the specified version:node-nightly --version {version}Or install the latest arrangements:node-nightly --upgradeTry to fix the problem

My name is Xiaoxin.

  • 😇 Familiar with: Android development, front-end development.
  • ðŸĪŠ Understand: back-end development, script development.
  • 🧐 specialty: solve difficult and miscellaneous diseases in coding.
  • 😇 motto: a thousand miles, small streams to become rivers and oceans.