Cannot write file because it would be overwritten by multiple input files
See original GitHub issueI keep having a problem where ts-node won’t work with multi-module projects. The local modules are linked using npm link. They often reference each other so a dependency(npm link) chain may look like A -> B -> C (project’s submodule depends on a “commons” module) + (project depends on “commons” module for type definitions etc.) A -> C But that’s probably not the main cause on this problem?
This breaks developer experience very badly because I am unable to run unit tests with ts-node while developing, so I have to go every time $ npm run build $ mocha lib/tests/test_something.js etc…
TSError: ⨯ Unable to compile TypeScript
Cannot write file 'C:/Users/x/IdeaProjects/PROJECT/MODULE1/$$ts-node$$/SYMLINKED_SUBMODULE/lib/src/util/index.js' because it would be overwritten by multiple input files. (5056)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top Results From Across the Web
visual studio - Typescript error "Cannot write file ... because it ...
Cannot write file 'C:/{{my-project}}/node_modules/buffer-shims/index.js' because it would overwrite input file. It looks like this all the time.
Read more >Error "Cannot write file ... because it would overwrite input file."
This happens when the declaration files are not excluded from the build. Whenever this occurs, the builder tries to build the existing ".d.ts" ......
Read more >Cannot write file because it would overwrite input file TS
The error "Cannot write file because it would overwrite input file" occurs when we haven't specified the outDir directory in the exclude array...
Read more >TypeScript: cannot write file .d.ts because it would overwrite ...
Then the error is pretty obvious and the fix should be too (don't output the generated declarations in the same place as types...
Read more >Error “Cannot write file … because it would overwrite input file.”
In this post am going to share with you the irritating typescript warnings and how it was solved for me. Below is the...
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 Free
Top 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

it seems like the problem is caused by using allowJs=true and removing it from tsconfig helps 🤔
My only guess is that you have both
.jsand.tsright next to each other. TypeScript would be resolving the.tsfile during compilation, but node.js would be resolving the.jsfile during resolution. WhenallowJsis enabled it’d be trying to compile.jswhen node.js loads the file, resulting in the overlap.