Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Cannot find module ..." when running TypeDoc outside of TS project folder #1300

Closed
davidjenkins opened this issue May 8, 2020 · 2 comments
Labels
bug Functionality does not match expectation

Comments

@davidjenkins
Copy link

Expected Behavior

Compile same as calling tsc directly when specifying path to tsconfig file.

Calling tsc directly from any directory like tsc -project /path/to/some/far/away/tsconfig.json works without any problems.

Actual Behavior

Cannot find typings in node_modules folder that is in same folder as tsconfig file. Throws errors like "Cannot find module '<module_name>'.".

Steps to reproduce the bug

  • Create project folder for source code (/my-library/src)
    • with tsconfig.json file
    • with node_modules folder
      • with various typings in @types folder
  • Create project folder for docs (/my-library/docs)
    • with package.json file
      • with typedoc depedency
      • with typescript depedency
      • with build script to run typedoc "typedoc --json api.json --tsconfig ../src/tsconfig.json"
  • Run build script, throws errors about not finding typings that exist in the node_modules folder that is in the same folder as the tsconfig file.

Environment

  • Typedoc version: 0.17.6
  • TypeScript version: 3.8.3
  • Node.js version: 12.16.3
  • OS: Windows 10

Workarounds

  • Use build script to change current working directory, like "cd ../src && typedoc --json ../docs/api.json --tsconfig tsconfig.json"
  • Use --ignoreCompilerErrors
@davidjenkins davidjenkins added the bug Functionality does not match expectation label May 8, 2020
@Gerrit0
Copy link
Collaborator

Gerrit0 commented May 17, 2020

So, turns out that the undocumented configFilePath property that shows up in the return value from parseJsonConfigFileContent is important. If you delete it, then when you create a program without it you'll end up with a program that can't always find @types packages... When reworking the options, it showed up and since it didn't seem to do anything, I just deleted it. Restoring it and adding a dummy option for it fixes this.

// This is not a TS option, but TypeScript will add it to the compiler options
// so we need to remove it or TypeDoc will error since it isn't declared.
'configFilePath'

@Gerrit0
Copy link
Collaborator

Gerrit0 commented May 17, 2020

v0.17.7 released with a fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants