最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to use jsdoc in local project - Stack Overflow

programmeradmin1浏览0评论

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 mand npm install --save jsdoc, and the install pleted 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 am in the wrong directory. If so, where should I be? (other than the project root folder)
  • The installation had a problem, even though it was successfull.

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?

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 mand npm install --save jsdoc, and the install pleted 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 am in the wrong directory. If so, where should I be? (other than the project root folder)
  • The installation had a problem, even though it was successfull.

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?

Share Improve this question asked Jun 23, 2016 at 11:00 Flame_PhoenixFlame_Phoenix 17.6k40 gold badges145 silver badges284 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

To run jsdoc in the mand 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 mand.

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

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

发布评论

评论列表(0)

  1. 暂无评论