我有一个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。有人以前遇到过这种情况吗?


当前回答

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

项目构建成功!

其他回答

我的VSCode在我的tsconfig开始时给了我一条弯曲的线。Json文件,有同样的错误,所以

我确保在“包括”路径中指定的文件夹中至少有一个.ts文件(包括路径中的一个文件夹是空的,这是正常的) 我只是关闭VSCode并重新打开它,这就解决了问题。(唉. .)

我的文件夹结构

    tsconfig.json
    package.json
    bar/
         myfile.ts
    lib/
         (no file)

我tsconfig.json

   "compilerOptions": { ... },
   "include": [
    "bar/**/*",
    "lib/**/*"
   ],
   "exclude": [
    ".webpack/**/*",
    ".vscode/**/*"
   ]
   

顺便说一下,我也遇到了同样的问题。

如果你有我的案例,那么你可能有tsconfig。Json和.ts文件不在同一个目录下。

(就我而言,我愚蠢地选择了next。Json和任务。在.vscode文件夹中添加。

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

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

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

你需要有两个文件夹,一个用于源代码(typescript),另一个用于输出(javascript)。

tsconfig.json:

{
  "compilerOptions": {
...
    "outDir": "out/", 
    "rootDir": "src/", 
...

我犯了同样的错误,因为我有这个:

"include": [ 
    "wwwroot/ts/*.ts" 
  ],
  "exclude": [ 
    "node_modules",
    "wwwroot"
  ]

出现错误是因为文件夹wwwroot出现在include和exclude中,您应该退出其中一个。