Flame_Phoenix
Flame_Phoenix

Reputation: 17604

how to use jsdoc in local project

Goal

I want to use jsdocs with npm.

Background

I am new to npm and its plugins. Recently I found out about jsdoc and I tried using it, with no success.

What I tried

First I installed the package using npm's command npm install --save jsdoc, and the install completed successfully.

However, when I try to use it in my project (I am inside the project's folder) I type jsdoc example.js and I get the following error:

/home/ubuntu/.nvm/versions/node/v4.4.5/bin/jsdoc: No such file or directory

This leads me to think that:

I have also tried to run npm jsdoc example.js but I get another error (this time from npm, saying I am not using it correctly).

I also installed jsdoc globally (using the -g flag) and it worked, but I truly want to avoid this because not all projects are using jsdoc.

Summary

To conclude, I am looking for a way to run jsdoc locally to a project with npm. Does anyone know of a way to do this?

Upvotes: 3

Views: 6291

Answers (2)

Jiří
Jiří

Reputation: 535

For local installation, the binary is in node_modules/.bin/jsdoc. If you install it globally, it should be accessible as jsdoc command. It's stated pretty early in the docs. https://www.npmjs.com/package/jsdoc

Upvotes: 0

Shriram Manoharan
Shriram Manoharan

Reputation: 585

To run jsdoc in the command line, the location of the jsdoc needs to be known. So when you have installed jsdoc globally, system would be able to find the file.

However if you want to run it locally, you need to include the file location before the jsdoc command.

For example, try using ./node_modules/jsdoc/jsdoc.js example.js

Upvotes: 5

Related Questions