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.
The "Cannot find module or its corresponding type declarations" error occurs when TypeScript cannot locate a third-party or local module in our project. To solve the error, make sure to install the module and try setting moduleResolution to node in your tsconfig.json file. If the module is a third-party module, make sure you have it installed.
# Why Does the "Cannot find module" Error Happen When Loading Fonts? It happens because of module resolution. You need to declare the font file formats as modules so that TypeScript can understand and parse them correctly. TypeScript relies on definition files (*.d.ts) to figure out what an import refers to.
It happens because of module resolution. You need to declare the font file formats as modules so that TypeScript can understand and parse them correctly. TypeScript relies on definition files ( *.d.ts) to figure out what an import refers to. When that information is missing, you get the "Cannot find module" error.
If the module is a third-party module, make sure you have it installed. Make sure to replace module-name with the name of the module in your error message. If it is a third-party module you're having problems with, try removing your node-modules and package-lock.json files, re-run npm install and reload your IDE.
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",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With