Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 NodeJS/Typescript overwriting node startup file

I keep getting the following error:

Error Code: TS5055  
Cannot write file C:/project/dir/server.js' because it would overwrite input file.
Project: TypeScript/JavaScript Virtual Projects

I even tried changing my entry filename to nodeserver.js and after a while I get the same error:

Error Code: TS5055  
Cannot write file C:/project/dir/nodeserver.js' because it would overwrite input file.
Project: TypeScript/JavaScript Virtual Projects

How can I find out what component is trying to overwrite it?

I did notice the file has the BuildAction set to Compile and 'Publish' to true. Could this be the cause? What is the implication of turning off Compile for a .js file? Will I not get any error checking?

Config Files

My tsconfig.json

{
  "compileOnSave": true,
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "isolatedModules": false,
    "jsx": "react"
  },
  "exclude": [
    "node_modules",
    "public",
    "server.js",
    "Scripts/typings/main",
    "Scripts/typings/main.d.ts"
  ],
  "filesGlob": [
    "./src/**/*.ts",
    "./src/**/*.tsx"
  ]
}

My package.json

{
  "name": "contract-vs-paye-calc-type-script",
  "version": "0.0.0",
  "description": "ContractVsPayeCalcTypeScript",
  "scripts": {
    "start": "node nodeserver.js",
    "lint": "eslint src"
  },
  "main": "/src/App.js",
  "author": {
    "name": "MC",
    "email": "[email protected]"
  },
  "dependencies": {
    "babel-core": "^6.7.7",
    "babel-loader": "^6.2.4",
    "express": "3.4.4",
    "jade": "*",
    "react": "^15.0.1",
    "react-dom": "^15.0.1",
    "react-hot-loader": "^1.3.0",
    "stylus": "*",
    "webpack": "^1.13.0",
    "webpack-dev-server": "^1.14.1"
  },
  "module": {
    "loaders": [
      {
        "test": "/\\.ts(x?)$/",
        "loader": "babel-loader!ts-loader"
      }
    ]
  }
}
like image 808
Michal Ciechan Avatar asked Apr 22 '16 11:04

Michal Ciechan


1 Answers

It seems that typescript compiler tries to transpile everything, including files that are already javascript. The solution is to add a new field outDir, to the compilerOptions, so it looks like this:

{
    ...
    "compilerOptions": {
        ...
        "outDir": "generated"
    }
    ...
}
like image 180
lesyk Avatar answered Oct 13 '22 04:10

lesyk