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


当前回答

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

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

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

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

其他回答

"outDir"

应该不同于

"rootDir"

例子

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

对我来说有效的解决方案是在配置文件中的每个include路径之前添加一个./:

"include": ["./src/**/*.d.ts", "./src/**/*.js", "./src/**/*.svelte"]

将一个.ts文件添加到项目根目录(与。tsconfig文件)。

因此,在我的例子中,我添加了一个.ts文件,并将其命名为main.ts。

在我的.tsconfig文件中,我包含了main.ts。

{
  "include": ["src/**/*", "main.ts"]
}

如果你正在使用VSCode,并且你打开了几个文件夹,那么你需要打开你正在工作的一个文件夹,让它消失。

错误打开文件夹 文件夹右打开

好的,在2021年,有一个<project>/src/index。Ts文件,以下对我有用:

如果VS Code抱怨在配置文件中没有发现输入…然后将include更改为…

“包括”:["。/ src / * * / * .ts”)

在《如何用Typescript编写Node.js应用程序》中找到了上面的注释