19

Forgive me if this is a daft question but I'm utterly baffled as to how I can use JSDoc on Windows. I'm aware of JSDoc-Toolkit but it's a bit out of date and the google code repository recommends to use JSDoc 3 instead. I have downloaded JSDoc from Github and unzipped the jsdoc-master folder onto my local disk but can't find any solid information as to how to use it to parse my files.

4 Answers4

24

You can download it as an npm package for the Node.js JavaScript runtime environment.

  1. Install Node.js which comes with npm
  2. Open your a command line
  3. Install JsDoc by typing the following command

    npm install -g jsdoc

  4. Run JsDoc / generate documentation. more info

    jsdoc path/to/file.js

  5. Configure jsdoc (Optional)

Simon Merrick
  • 732
  • 4
  • 13
  • 1
    Thanks, the -g option is very useful! Saves having to run it from the .bin folder – OhMyGodThereArePiesEverywhere Nov 27 '15 at 01:18
  • Even so you dont need to run it from the `.bin` folder. npm creates the `node_modules` folder and installs the package in the current working directory unless the `-g` option is passed. So if you are not installing it globally you should `cd path/to/project_root` before you run `npm install` – Simon Merrick Nov 27 '15 at 01:21
  • Thanks, one last question: when installing globally, where is the jsdoc folder placed (so I can put templates in there)? I have node.js installed on D:\node, and I've checked the `node_modules` subfolder(s) (inc. in npm). – OhMyGodThereArePiesEverywhere Nov 27 '15 at 01:31
  • Actually, my apologies, you are half right. If you didn't install it globally, you either need to `cd` down to the `.bin` folder or add the path to jsdoc to the start of the command - I refuse to be more specific as this is the wrong way to do it. **You should always install jsdoc globablly**. – Simon Merrick Nov 27 '15 at 01:31
  • 1
    I'm pretty sure on windows it puts global node modules in your user folder `C:/Users//node_modules` – Simon Merrick Nov 27 '15 at 01:33
  • You are indeed correct! Thank you for your help, everything is now working correctly. – OhMyGodThereArePiesEverywhere Nov 27 '15 at 01:38
  • in windows 10 I am getting "this program is blocked by group policy..." when I try to run jsoc in command prompt (as adminstrator) – CodeToad Jan 05 '16 at 09:58
  • I doubt your network admin has explicitly blocked JSDoc, its probably a higher level restriction on all executables run from a path (or not running from a path) or something. I would suggest trying a bunch of other node tools to see if you get the same error and also trying some other non-node commands like `ping`, `nslookup` or another system command, - even try some ruby gems or python [whatevers] and see if they are also blocked by group policy. Maybe you could open a question on SuperUser if this doesnt work – Simon Merrick Jan 05 '16 at 22:48
  • Before running the command to install, I had to run "npm init" to generate the .json file – AllisonC Oct 02 '18 at 12:16
  • I'm on Windows 10 but I don't have a `C:/Users//node_modules` folder. The only way I found to run jsdoc is `npx jsdoc`. – Jean Paul Apr 09 '21 at 13:59
  • You don't need to `cd` into the `.bin` directory. You should be able to type `npx jsdoc` to execute it, or make an npm/yarn script: `yarn doc` that runs the normal jsdoc command. – R891 Jan 30 '23 at 06:35
0

The installation is not good documented on the project-page.

It is much better exlained on the github-page.

selcox
  • 15
  • 4
0

I don't know very much about NodeJS/npm ecosystem. However, I did the following steps below and it worked for me (on windows):

  1. Downloaded NodeJS zip file and extracted, it made a directory 'node-v16.15.1-win-x64' with node.exe and and npm.cmd inside
  2. Executed command 'npm install -g jsdoc', under the 'node_modules' directory under the 'node-v16.15.1-win-x64' it installed the jsdoc (in a folder) and also made the jsdoc.cmd file inside 'node-v16.15.1-win-x64'.
  3. This jsdoc.cmd works with the full path but it does not work without the full path jsdoc gets installed and is working with the above steps but to access it from any where without giving the full path, I had to set the 'node-v16.15.1-win-x64' on Windows PATH, that works.

I am not sure if question of OP is answered but JSDoc works for me this way.

Ironluca
  • 3,402
  • 4
  • 25
  • 32
-1

I'm not saying this is necessarily the best way, but it worked for me:

  1. Install node.js

  2. Open a command prompt

  3. As a test, create a folder in your root drive (c:\test) and go to it (cd\test). I guess there was some sort of permission issue as I couldn't get the following steps to work in my desktop folder.

  4. Install the JSDoc package: npm install jsdoc

  5. There should be a folder in test called node_modules

  6. Go to the .bin subfolder in node_modules

  7. There should be a file called jsdoc.cmd. Simple use jsdoc myfile.js in the command prompt to execute the JSDoc script on your file

chrisweb
  • 1,428
  • 19
  • 25