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


当前回答

将index.js更改为index。它为我修复了这个错误。(在此之前我没有任何.ts文件)。

注意:记住在你引用index.js的任何地方都要改成index。当然,除非你引用你的主文件。按照惯例,这可能在你的lib或dist文件夹中。 我的tsconfig.json:

{
  "compilerOptions": {
    "target": "es2016",
    "module": "commonjs",
    "outDir": "./dist",
    "strict": true,
    "esModuleInterop": true,
    "inlineSourceMap": true,
    "noImplicitAny": false
  }
}

我的outDir是。/dist,所以我在包中引用了main。"dist/index.js"

其他回答

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

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

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

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

当我在同一目录下对node_modules文件夹进行备份时,我收到了同样的错误。当发生这种情况时,我正在尝试解决一个不同的构建错误。我希望这个场景能帮助到一些人。删除备份文件夹,构建将完成。

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

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

对我来说,解决方案是将文件夹传递到本地磁盘,在我将文件夹复制到谷歌驱动器存储库(g:/)。当拷贝回来的时候,所有工作都很好。

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

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

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

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