我有一个ASP。NET核心项目,我得到这个错误时,我试图构建它:

error TS18003: Build:No inputs were found in config file 'Z:/Projects/client/ZV/src/ZV/Scripts/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["../wwwroot/app","node_modules/*"]'.
1>         The command exited with code 1.
1>       Done executing task "VsTsc" -- FAILED.

这是我的tsconfig。json文件:

{
  "compileOnSave": true,
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es5", "dom" ],
    "module": "commonjs",
    "moduleResolution": "node",
    "noEmitOnError": true,
    "noImplicitAny": false,
    "outDir": "../wwwroot/app/",
    "removeComments": false,
    "sourceMap": true,
    "target": "es6"
  },
  "exclude": [
    "../wwwroot/app",
    "node_modules/*"
  ]
}

这是bug还是我做错了什么?我最近把Visual Studio 2015升级到3。有人以前遇到过这种情况吗?


当前回答

当您创建tsconfig。Json文件的TSC——init,然后注释输入和输出文件目录。这就是错误的根本原因。

要解决这个问题,取消注释这两行:

"outDir": "./", 
"rootDir": "./", 

在取消注释后,它最初看起来像上图。

但是我所有的。ts脚本都在src文件夹中。我指定了/src。

"outDir": "./scripts", 
"rootDir": "./src", 

请注意,您需要在rootDir中指定.ts脚本的位置。

其他回答

对于遇到相同错误的任何人,都应该尝试将“node modules”添加到排除选项中

{
   "compilerOptions": {
     ...
   },
   "include": [
      "./src/**/*.ts"
   ],
   "exclude": [
      "./out.d.ts",
      "node_modules",
   ]
}

我把所有的.ts文件都放在src文件夹中,它是tsconfig.json的兄弟文件夹。当我的include看起来像这样时,我得到了这个错误(它之前是工作的,一些依赖升级导致错误显示):

"include": [
    "src/**/*"
],

改成这样就解决了我的问题:

"include": [
    "**/*"
],

当使用Visual Studio Code构建项目时(即按Ctrl + Shift + B),将.ts文件移动到.vscode文件夹中(我不知道为什么它这样做),然后生成TS18003错误。 我所做的就是将我的.ts文件从.vscode文件夹中移出,回到根文件夹中,并再次构建项目。

项目构建成功!

我用了这个 如何在。net核心项目中禁用TypeScript编译?

因为我使用模板,而那些包只需要我的模板。 然而,我可以在它们的node_module文件中看到每个包的导出。 如果你有同样的情况,你可以使用上面的链接

我必须将文件项添加到tsconfig中。Json文件,如下所示:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
    },
    "files": [
        "../MyFile.ts"
    ] 
}

更多详情请访问:https://www.typescriptlang.org/docs/handbook/tsconfig-json.html