TypeDoc抱怨“找不到模块" [英] TypeDoc complains "Cannot find module"
问题描述
我有一个基于Typsecript的react应用程序.它工作正常,但我想将TypeDoc(对于Typescript认为是JSDoc)添加到混合中.安装后,我从命令行运行它(仅在测试时处理单个文件):
I have a Typsecript based react app. It works fine but I want to add TypeDoc (think JSDoc for Typescript) to the mix. After installing it I run this from the command line (only processing a single file as I test this):
typedoc --module commonjs --jsx react --out ../docs/ ./src/components/404/404.tsx
我得到一个错误:
Error: /path/to/project/src/components/404/404.tsx(0)
Cannot find module 'react'.
实际上已经安装了
React.我试过运行在全局和本地安装的TypeDoc,这没有什么区别(可能是全局安装找不到正确的node_modules).该应用程序可以从Typescript编译并正常运行...不会抱怨缺少模块或键入defs ...只是无法通过TypeDoc正常工作.
React is, in fact, installed. I have tried running TypeDoc installed globally and locally and it makes no difference (thought maybe the global install was unable to find the correct node_modules). The app compiles from Typescript and runs fine... no complaints about missing modules or type defs... just won't work via TypeDoc.
有什么建议吗?似乎为了在基于Typescript的React项目中生成文档,TypeDoc是城里唯一的游戏,所以我有点受阻.
Any suggestions? It seems that in order to generate documentation in a Typescript based React project, TypeDoc is the only game in town so I'm a bit stuck.
推荐答案
可能对您有帮助:
'node ./node_modules/typedoc/bin/typedoc ' +
(path || './src/scripts/') +
'--exclude node_modules ' +
'--ignoreCompilerErrors ' +
'--experimentalDecorators ' +
'--target ES6 ' +
'--jsx react'
我注意到package.json中的默认主题出现了一些错误:
And I noticed some error in package.json with default theme:
-"typedoc-default-themes":"0.4.0",
++"typedoc-default-themes":"0.3.4",
这篇关于TypeDoc抱怨“找不到模块"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!