TypeDoc complains “Cannot find module”

空扰寡人 提交于 2021-01-22 06:36:09

问题


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

and I get an error:

Error: /path/to/project/src/components/404/404.tsx(0)
 Cannot find module 'react'.

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.

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.


回答1:


Probably it helps you:

'node ./node_modules/typedoc/bin/typedoc ' +
(path || './src/scripts/') +
'--exclude node_modules ' +
'--ignoreCompilerErrors ' +
'--experimentalDecorators ' +
'--target ES6 ' +
'--jsx react'

And I noticed some error in package.json with default theme:

-- "typedoc-default-themes": "0.4.0",

++ "typedoc-default-themes": "0.3.4",



来源:https://stackoverflow.com/questions/36140383/typedoc-complains-cannot-find-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!