Search code examples
node.jsnpmnpm-installnode-modulesapi-doc

'apidoc' is not recognized as an internal or external command


Im working on a nodejs server and trying to generate some documentation. as Ive read here:http://apidocjs.com/, Ive added the apidoc as a dependency to the project and ran:npm install everything went well and I do see node_modules/api_doc directory, however I cant seem to run apidoc -i myapp/ -o apidoc/ now I realise that for this to run I need to add to my environment variables the path to the apidoc\bin folder however this dosent make much sense to me as the npm install is only locally to my current project and not globaly for any project I make, what am I missing here and how do I make this work? Thanks in advance.


Solution

  • The apidoc command is placed under node_modules/.bin folder. You can try to place the command apidoc -i myapp/ -o apidoc/ under an npm script in you package.json.

    For example:

    "scripts": {
      "start": ...,
      "docs": "apidoc -i myapp/ -o apidoc/",
    }
    

    Now you can execute npm run docs to generate the documentation.

    If you do not want to use an npm script, you should can use npx apidoc -i myapp/ -o apidoc/ to generate the documentation. npx is available by default if you are using [email protected] or greater or can be installed from here.