[BUG] Compodoc tsconfig path resolution is broken on windows machines
See original GitHub issueOverview of the issue
If you run Compodoc with the -p
flag and pass in an absolute path on windows machines, it results in an error
Storybook passes in an absolute path like this
-p D:\Development\storybook-example\.storybook\tsconfig.json
and the result is
Error: error TS5083: Cannot read file 'D:\Development\storybook-example\D:\Development\storybook-example\.storybook\tsconfig.json'.
It seems like it adds process.cwd()
to the already absolut path and causes a duplication
We figured out that this might be the line where things go wrong for windows users
https://github.com/compodoc/compodoc/blob/develop/src/index-cli.ts#L708
We worked around this by always passing in a relative path https://github.com/storybookjs/storybook/pull/17334/files
Operating System, Node.js, npm, compodoc version(s)
Windows
node v16.13.1
@compodoc/compodoc: 1.1.18
If possible sourcecode of the file where it breaks
If possible your terminal logs before the error
compodoc -p D:\Development\storybook-example\.storybook\tsconfig.json -d D:\Development\storybook-example -e json
1.1.18
TypeScript version used by Compodoc : 4.5.5
TypeScript version of current project : 4.5.2
Node.js version : v16.13.1
Operating system : Windows 10
[09:28:06]
No configuration file found, switching to CLI flags.
[09:28:06]
Using tsconfig file : D:\Development\storybook-example\D:\Development\storybook-example\.storybook\tsconfig.json
D:\Development\storybook-example\node_modules\@compodoc\compodoc\dist\index-cli-a4b7f403.js:1016
throw new Error(message);
^
Error: error TS5083: Cannot read file 'D:\Development\storybook-example\D:\Development\storybook-example\.storybook\tsconfig.json'.
at readConfig (D:\Development\storybook-example\node_modules\@compodoc\compodoc\dist\index-cli-a4b7f403.js:1016:15)
at CliApplication.start (D:\Development\storybook-example\node_modules\@compodoc\compodoc\dist\index-cli-a4b7f403.js:13690:40)
at Object.<anonymous> (D:\Development\storybook-example\node_modules\@compodoc\compodoc\bin\index-cli.js:6:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
An unexpected error occurred: undefined
Reproduce the error
Use absolute path for -p
flag on windows machines
Suggest a Fix
Probably add another else if
or update
let _file = path.join(
path.join(process.cwd(), path.dirname(Configuration.mainData.tsconfig)),
path.basename(Configuration.mainData.tsconfig)
);
As said, in Storybook we fixed it using this code:
const toRelativePath = (pathToTsConfig: string) => {
return path.isAbsolute(pathToTsConfig) ? path.relative('.', pathToTsConfig) : pathToTsConfig;
};
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Why are these tsconfig paths not working? - Stack Overflow
You can see that a path such as shared/someFolder/someScript will resolve correctly to the shared folder in my project, which is a load...
Read more >cannot find module 'rxjs' or its corresponding type declarations ...
I am experiencing Typescript errors: Error TS2307 (TS) Cannot find module 'rxjs/internal-compatibility' or its corresponding type declarations.
Read more >@storybook/client-logger | Yarn - Package Manager
Any client-side logging that is done through storybook should be done through this package. Examples: import { logger } from '@storybook/client-logger' ...
Read more >ashwani8077 - npm Package Health Analysis - Snyk
Create a simple-logger folder on your computer. mkdir simple-logger ... Report error when not all code paths in function return a value.
Read more >Common TypeScript module problems and how to solve them
Enabling the compiler module resolution tracing in TypeScript can provide insight in diagnosing and solving problems.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kroeder Cannot reproduce the bug with the demo project (https://github.com/compodoc/compodoc-demo-todomvc-angular) on Windows. Could you make one with storybook installed ? thanks
This issue has been automatically closed because it has not had recent activity. Please file a new issue if you are encountering a similar or related problem. Thank you for your contributions.