0

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.

4

1 回答 1

3

apidoc命令放在node_modules/.bin文件夹下。您可以尝试将命令apidoc -i myapp/ -o apidoc/放在 package.json 中的 npm 脚本下。

例如:

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

现在您可以执行npm run docs以生成文档。

如果您不想使用 npm 脚本,您应该可以使用它npx apidoc -i myapp/ -o apidoc/来生成文档。npx如果您正在使用npm@5.2.0或更高版本,则默认情况下可用,或者可以从此处安装。

于 2018-08-26T10:39:22.857 回答