node.js - '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.
解决方案
该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
或更高版本,则默认情况下可用,或者可以从此处安装。
推荐阅读
- swift - Swift 4.2:以下声明是什么意思
- windows - 安装新版本 Slack 时出错:暂存用户 ID 和其他错误
- c++ - 如何使用 boost::wregex?
- node.js - Mobx-state-tree SSR 双初始化客户端和服务器
- storage - 如何创建 OpenEBS cstor 池?
- ios - CSS 未在 iOS 设备上应用
- xcode - 错误:在使用 OneSignal 进行推送注册期间遇到错误:错误域 = OneSignalError 代码 = 400“
- elasticsearch - 弹性搜索高内存消耗
- swift4 - 谷歌地图奇怪的行为swift 4 ios
- module - target_link_libraries 在链接时错误地拉入 MODULE 库