question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot write file because it would be overwritten by multiple input files

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
ninja-commented, Sep 27, 2017

it seems like the problem is caused by using allowJs=true and removing it from tsconfig helps 🤔

4reactions
blakeembreycommented, Oct 5, 2017

My only guess is that you have both .js and .ts right next to each other. TypeScript would be resolving the .ts file during compilation, but node.js would be resolving the .js file during resolution. When allowJs is enabled it’d be trying to compile .js when node.js loads the file, resulting in the overlap.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found