Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use jsdoc in my script running on node.js?

I would like to use jsdoc module to extract documentation entries from some source code. I have installed jsdoc module and I can use jsdoc in the command line. But when I require("jsdoc") in my code, nodejs throws an error saying Cannot find module 'jsdoc'.

I have nodejs v0.8.25 and JSDoc 3.3.0-alpha2. It is installed both locally and globally. I can use jsdoc command and I have jsdoc in my node_modules folder. I cannot see where the problem is.

Where can I find some documentation about jsdoc other than how to use it in the command line interface or how to document js source code. I would like some API documentation.

like image 667
Richard Dong Avatar asked Nov 28 '13 03:11

Richard Dong


1 Answers

I was looking to use jsdoc as a library too, and I stumbled on the same issue as you did. You have done nothing wrong, it was just never intended to be used as a library.

There is an issue on the jsdoc's github project page relating to this. Hegemonic, the main contributor of JSDoc said:

JSDoc isn't really designed to be used as a library

You might want to express your desire to for creating an API for nodejs on the issue linked above.

The require('jsdoc') fails because there is no main field declared in the jsdoc's package.json. It might default to 'index.js' or 'main.js', but there is no such file either.

like image 200
Cristi Mihai Avatar answered Oct 05 '22 10:10

Cristi Mihai