簡體   English   中英

Visual Studio 2015 NodeJS / Typescript覆蓋節點啟動文件

[英]Visual Studio 2015 NodeJS/Typescript overwriting node startup file

我一直收到以下錯誤:

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

我甚至嘗試將我的條目文件名更改為nodeserver.js ,過了一會兒我得到了同樣的錯誤:

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

如何找出試圖覆蓋它的組件?

我注意到該文件將BuildAction設置為Compile並將'Publish'設置為true。 這可能是原因嗎? 關閉.js文件的Compile有什么意義? 我不會得到任何錯誤檢查嗎?

配置文件

我的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"
  ]
}

我的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": "admin@admin.com"
  },
  "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"
      }
    ]
  }
}

似乎typescript編譯器試圖轉換所有內容,包括已經是javascript的文件。 解決方案是將新字段outDir添加到compilerOptions,所以它看起來像這樣:

{
    ...
    "compilerOptions": {
        ...
        "outDir": "generated"
    }
    ...
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM