tsconfig.json:构建:在配置文件中找不到输入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41211566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
tsconfig.json: Build:No inputs were found in config file
提问by rood
I have an ASP.NET core project and I'm getting this error when I try to build it:
我有一个 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.
This is my tsconfig.jsonfile:
这是我的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/*"
]
}
Is this a bug or am I doing something wrong? I did recently upgrade Visual Studio 2015 to update 3. Has anyone encountered this before?
这是一个错误还是我做错了什么?我最近确实将 Visual Studio 2015 升级到更新 3。有没有人遇到过这种情况?
回答by rood
Add an empty typescript file to the typescript scripts folder (the location of your tsconfig file) to satisfy the typescript compiler.
将一个空的打字稿文件添加到打字稿脚本文件夹(您的 tsconfig 文件的位置)以满足打字稿编译器。
回答by desoga
You can also try to restart your code editor. That works well too.
您也可以尝试重新启动代码编辑器。这也很好用。
回答by TreeAndLeaf
I'm not using TypeScript in this project at all so it's quite frustrating having to deal with this. I fixed this by adding a tsconfig.json and an empty file.ts file to the project root. The tsconfig.json contains this:
我在这个项目中根本没有使用 TypeScript,所以不得不处理这个非常令人沮丧。我通过向项目根目录添加一个 tsconfig.json 和一个空的 file.ts 文件来解决这个问题。tsconfig.json 包含以下内容:
{
"compilerOptions": {
"allowJs": false,
"noEmit": true // Do not compile the JS (or TS) files in this project on build
},
"compileOnSave": false,
"exclude": [ "src", "wwwroot" ],
"include": [ "file.ts" ]
}
回答by FrostyDog
If you've got an includearray (which is what the TypeScript linter is likely complaining about):
如果你有一个include数组(这就是 TypeScript linter 可能抱怨的):
tsconfig.json
配置文件
{
...
"include": [
"./src/"
],
}
and you're using VSCode, you can restart your TS server within your editor super easily to prompt it to re-evaluate the file.
并且您正在使用 VSCode,您可以非常轻松地在编辑器中重新启动 TS 服务器,以提示它重新评估文件。
CMD+ SHIFT+ P(on Mac) will open the command prompt, and then find the TypeScript: Restart TS servercommand
CMD+ SHIFT+ P(在Mac上)将会打开命令提示符,然后找到TypeScript: Restart TS server命令
回答by Susampath
If you are using the vs code for editing then try restarting the editor.This scenario fixed my issue.I think it's the issue with editor cache.
如果您使用 vs 代码进行编辑,请尝试重新启动编辑器。这种情况解决了我的问题。我认为这是编辑器缓存的问题。
回答by Pran Kumar Sarkar
When you create the tsconfig.jsonfile by tsc --init, then it comments the input and output file directory. So this is the root cause of the error.
当您通过创建tsconfig.json文件时tsc --init,它会注释输入和输出文件目录。所以这是错误的根本原因。
To get around the problem, uncomment these two lines:
要解决此问题,请取消注释这两行:
"outDir": "./",
"rootDir": "./",
Initially it would look like above after un-commenting.
最初它在取消注释后看起来像上面一样。
But all my .ts scripts were inside src folder. So I have specified /src.
但是我所有的 .ts 脚本都在 src 文件夹中。所以我指定了/src。
"outDir": "./scripts",
"rootDir": "./src",
Please note that you need to specify the location of your .ts scripts in rootDir.
请注意,您需要在 rootDir 中指定 .ts 脚本的位置。
回答by Inukollu Hari krishna
I am getting this error, "No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["**/*"]'and 'exclude' paths were '["**/*.spec.ts","app_/**/*.ts","**/*.d.ts","node_modules"]'.
我收到此错误,“在配置文件 'tsconfig.json' 中找不到输入。指定的 'include' 路径'["**/*"]'和 'exclude' 路径是'["**/*.spec.ts","app_/**/*.ts","**/*.d.ts","node_modules"]'.
I have a .tsconfig file, which reads ts files from "./src" folder.
我有一个 .tsconfig 文件,它从“./src”文件夹中读取 ts 文件。
The issue here is with that source folder not containing .ts files and i am running tslint. I resolved issue by removing tslint task from my gulp file. As i don't have any .ts files to be compiled and linted. My issue is resolved by doing this.
这里的问题是该源文件夹不包含 .ts 文件,我正在运行 tslint。我通过从我的 gulp 文件中删除 tslint 任务解决了问题。因为我没有任何要编译和检查的 .ts 文件。通过这样做,我的问题得到了解决。
回答by Rajat Kumar
add .ts file location in 'include' tag then compile work fine. ex.
在 'include' 标签中添加 .ts 文件位置,然后编译工作正常。前任。
"include": [
"wwwroot/**/*" ]
回答by Corey Cole
I have all of my .ts files inside a srcfolder that is a sibling of my tsconfig.json. I was getting this error when my includelooked like this (it was working before, some dependency upgrade caused the error showing up):
我的所有 .ts 文件都在一个src文件夹中,该文件夹是我的 .ts 文件的同级文件夹tsconfig.json。当我include看起来像这样时,我收到了这个错误(它之前工作,一些依赖升级导致错误显示):
"include": [
"src/**/*"
],
changing it to this fixed the problem for me:
将其更改为此为我解决了问题:
"include": [
"**/*"
],
回答by Randell Lamont
When using Visual Studio Code, building the project (i.e. pressing Ctrl+ Shift+ B), moves your .tsfile into the .vscode folder(I don't know why it does this), then generates the TS18003 error. What I did was move my .tsfile out of the .vscode folder, back into the root folderand build the project again.
使用Visual Studio Code 时,构建项目(即按Ctrl+ Shift+ B),将您的.ts文件移动到.vscode 文件夹(我不知道它为什么这样做),然后生成TS18003 错误。我所做的是将我的.ts文件移出.vscode 文件夹,回到根文件夹并再次构建项目。
The project built successfully!
项目搭建成功!


