问题
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