Tuesday, August 11, 2020

How to debug js code in third party npm package

Note

Before debugging the npm source code, you may want to try to run the npm command with verbose level log, the log may provide some details for you to solve the issue instead of debugging the code. To enable to verbose level log, run the npm command with below command

npm mycommand --loglevel verbose



When using third party npm package in your js app, sometimes you will need to debug the js code to figure out issues. 

Quite often, the third party npm package js code is minified, so as to load them faster. But during debug, you will want to load the no-minified js file. An easy way to do so is open the third party package.json file, and update main element's value to point to the debug version js entry point.

For example, to debug oidc-client.js, in package.json, make the below change

 "homepage": "https://github.com/IdentityModel/oidc-client-js",
  "license": "Apache-2.0",
  "main": "lib/oidc-client.js", "lib/oidc-client.min.js"
  "name": "oidc-client",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/IdentityModel/oidc-client-js.git"

  }, 

No comments:

Post a Comment