Typescript error “Cannot write file … because it would overwrite input file.”

后端 未结 19 1332
醉梦人生
醉梦人生 2021-02-01 12:04

In my Typescript 2.2.1 project in Visual Studio 2015 Update 3, I am getting hundreds of errors in the error list like:

Cannot write file \'C:/{{my-project

相关标签:
19条回答
  • 2021-02-01 12:34

    I got the same issue. In my case, it was the result of the option: allowJs: true.

    So I basically had to remove that line to get rid of the errors. I do not see it in your code, but perhaps it helps you here.

    Good luck!

    0 讨论(0)
  • 2021-02-01 12:34

    this config works for me

    "allowJs": true
    
    0 讨论(0)
  • 2021-02-01 12:35

    Adding 'dist' to the excluded directories in tsconfig.json worked for me:

    {
      "exclude": ["node_modules", "dist"]
    }
    
    0 讨论(0)
  • 2021-02-01 12:35

    Probably the root of the problem is 2 files generating the same module. So if one have two files in the same folder with the same name but with different extensions leads to this error.

    eg:

    \index.ts
    \index.tsx
    

    Solution is changing one of these files names to something else.

    0 讨论(0)
  • 2021-02-01 12:36

    I had this issue too. In my case, I restored the original version of file \tools\JsEngine\typescriptServices.js and it solved.

    I found that typescriptServices.js was changed by Visual Studio, because of the end of the line (CRLF or CR), and after that VS cannot run it in a correct way.

    0 讨论(0)
  • 2021-02-01 12:38

    Most likely, this happens when you try to run one project with two nodes. For this hypothesis, you can test the count of processes on your computer named "node" after run build. What I did to solve the problem:

    Step 1.

    Compare

    node -v
    

    and

    nvm -ls
    

    , the version in use. In terminal set current node version:

    nvm use {neededVersion}
    

    In principle, delete unnecessary versions of the node in nvm (this will help your IDE to automatically determine the normal version of the node).

    Step 2.

    Determine the current node in your IDE. i.e. in WebStorm: Preferencies->Languages & Frameworks -> Node.js and NPM | Typescript: Node interpreter - set needed version.

    0 讨论(0)
提交回复
热议问题