I also wanted to use jsdoc as a library, and I came across the same problem as you. You didnβt do anything wrong, it was just not meant to be used as a library.
the problem is on the jsdoc github project page related to this. Hegemonic , a major contributor to JSDoc, said:
JSDoc is not intended to be used as a library
You might want to express your desire to create an API for nodejs on the issue related above.
require('jsdoc') crashes because the main field is not specified in jsdoc package.json . It may default to specifying "index.js" or "main.js", but there is also no such file.
Cristi mihai
source share