Error ts18003 no inputs were found in config file

Add an empty typescript file to the typescript scripts folder the location of your tsconfig file to satisfy the typescript compiler

I have an ASP.NET core project and I’m getting this error when I try to build it:

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.json file:

{
  "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?

1) Solution

Add an empty typescript file to the typescript scripts folder (the location of your tsconfig file) to satisfy the typescript compiler.

2) Solution

You can also try to restart your code editor. That works well too.

3) Solution

This can occur because typescript server can’t find any files described by the include array:

// tsconfig.json
{
  //...
  "include": [
    "./src/"
  ],
}

If you’re using VSCode, you can restart your TS server within your editor super easily to prompt it to re-evaluate the file like this:

  1. Navigate to any .ts or .tsx file

  2. Open the command palette (CMD + SHIFT + P on mac)

  3. Run the TypeScript: Restart TS server command:

    TypeScript - Restart TS Server

4) Solution

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:

{
  "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" ]
}
5) Solution

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.

6) Solution

I have all of my .ts files inside a src folder that is a sibling of my tsconfig.json. I was getting this error when my include looked like this (it was working before, some dependency upgrade caused the error showing up):

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

changing it to this fixed the problem for me:

"include": [
    "**/*"
],
7) Solution

In modern typescript config just set «allowJs» and no need to add any empty .ts file in include directories such as «src» (specified in include array)

tsconfig.json

{
  "compilerOptions": {
    "allowJs": true,
   ...
  },
  "include": [
    "src"
  ]
}
8) Solution

When you create the tsconfig.json file by tsc --init, then it comments the input and output file directory. So this is the root cause of the error.

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.

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

Please note that you need to specify the location of your .ts scripts in rootDir.

9) Solution

I was getting this error:

No inputs were found in config file ‘tsconfig.json’.

Specified include paths were '["**/*"]' and exclude paths '["**/*.spec.ts","app_/**/*.ts","**/*.d.ts","node_modules"]'.

I had a .tsconfig file, which read TS files from the ./src folder.

The issue here was that with the source folder not containing any .ts files and I was 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.

10) Solution

Changing index.js to index.ts fixed this error for me. (I did not have any .ts files before this).

Note: remember to change anywhere you reference index.js to index.ts except of course, where you reference your main file. By convention this is probably in your lib or dist folders.
My tsconfig.json:

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

My outDir is ./dist so I reference my main in my package.json as "main": "dist/index.js"

enter image description here

11) Solution
"outDir"

Should be different from

"rootDir"

example

    "outDir": "./dist",
    "rootDir": "./src", 
12) Solution

You need to have the root index.tsx or index.ts file for the tsc command to work.

13) Solution

I added the following in the root ( visual studio )

{
  "compilerOptions": {
    "allowJs": true,
    "noEmit": true,
    "module": "system",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "include": [
    "**/*"
  ],
  "exclude": [
    "assets",
    "node_modules",
    "bower_components",
    "jspm_packages"
  ],
  "typeAcquisition": {
    "enable": true
  }
}
14) Solution

Ok, in 2021, with a <project>/src/index.ts file, the following worked for me:

If VS Code complains with No inputs were found in config file… then change the include to…

"include": ["./src/**/*.ts"]

Found the above as a comment of How to Write Node.js Applications in Typescript

15) Solution

The solution that worked for me was to add a ./ before each include path in the config file:

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

When using Visual Studio Code, building the project (i.e. pressing Ctrl + Shift + B), moves your .ts file into the .vscode folder (I don’t know why it does this), then generates the TS18003 error.
What I did was move my .ts file out of the .vscode folder, back into the root folder and build the project again.

The project built successfully!

17) Solution

add .ts file location in ‘include’ tag then compile work fine. ex.

"include": [
"wwwroot/**/*" ]
18) Solution

My VSCode was giving me the squiggly line at the beginning of my tsconfig.json file, and had the same error, so

  1. I made sure I had at least one .ts file in the folder specified in the «include» paths (one of the folders in the include path was empty and it was fine)
  2. I simply closed the VSCode and opened it back up, and that fixed it. (sigh..)

My folder structure

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

My tsconfig.json

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

If you don’t want TypeScript compilation, disable it in your .csproj file, according to this post.

Just add the following line to your .csproj file:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
20) Solution

I had to add the files item to the tsconfig.json file, like so:

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

More details here: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

21) Solution

Btw, just had the same problem.

If you had my case, then you probably have the tsconfig.json not in the same directory as the .ts file.

(In my case I stupidly had next to launch.json and tasks.json inside the .vscode folder :P)

22) Solution

I had existing tsconfig files for 4 existing projects in my solution. After upgrading to vs2017 I experienced this problem. It was fixed by adding the (supposedly default) include and exclude sections to the files, as described by NicoJuicy.

23) Solution

For anyone experiencing the same error should try adding «node modules» to the exclude options

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

I have a tsconfig.json file that doesn’t apply to any .ts files. It’s in a separate folder. Instead I only use it as a base for other tsconfig files via "extends": "../Configs/tsconfig.json". As soon as I renamed the base config file to something else e.g. base-tsconfig.json (and updated the extends statements) the error went away and the extending still worked.

25) Solution

I got the same error and in my case it was because vscode couldn’t recognize .ts file.

It was seeing it as text file and I had to rename it to remove one letter and add it back to make it work.

26) Solution

I ran into this issue constantly while packing my projects into nugets via Visual Studio 2019. After looking for a solution for ages I seem to have solved this by following advice in this article

MSBuild & Typescript (http://ticehurst.com/jsdocs/articles/configuration/msbuild.html)

especially part about <TypeScriptCompile /> where I included all my .ts resources with the Include operator and excluded others such as node_modules with the Remove operator. I then deleted the tsconfig.json file in each offending project and the nuget packages were generated and no more errors

27) Solution

I received this same error when I made a backup copy of the node_modules folder in the same directory. I was in the process of trying to solve a different build error when this occurred. I hope this scenario helps someone. Remove the backup folder and the build will complete.

28) Solution

I had the same error because I had this:

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

The error appear because the folder wwwroot appear in include and exclude, you should quit one of them.

29) Solution

Make sure all your files has a correct name.

30) Solution

You need to have two folders, one for the source (typescript) and another for the output (javascript).

tsconfig.json:

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

Comments Section

This is intended behavior. You need to have something to compile.

@AluanHaddad You state this as if it is fact. Can you please provide proof for your assertion.

github.com/Microsoft/TypeScript/issues/12762

what does this mean?

@Christian Matthew This means, you need to add a t least one typescript file to the folder where your app is to satisfy typescript compiler.

What do you mean by script folder. Can you please elaborate more??

Ironcially.. i used this answer a long time ago (added the tsconfig and it fixed this issue). When I added Vue to the project the issue popped up again… so I had to then delete the tsconfig I added in the past, and it worked :P

it puts the .tsconfig file into the .vscode folder. If you move it out of the .vscode folder, you may also need to edit .vscode/tasks.json to point to the new location

Your source should be where you’re pointing in «include» on tsconfig

Thanks. Working for me. But can anyone explain what’s actually happening behind?

Just an empty "exclude": [ "" ] works too (to override the default which is ./)

How do you get the TypeScript command? I only have e.g. File, Git, GitLens, etc

@Leo make sure you’re viewing a .js/.jsx/.ts/.tsx file when you look for the command. The command, for example, is not available when you’re viewing an .html file

The default tsconfig.json doesn’t have «include» and «exclude» props, so I had to add both. For some reason it seems that both were required

Works for VSC. You can just restart the TS Server in VSC. Thanks.

This can also be used for jsconfig.js. I am not using TS as well, but Vue and Vetur are starting to require this for some reason. That is a really bad architecture on their part.

restarting the ts server did it for me, didn’t know that was a thing, thanks

I was pulling my hair until I tried this :)

this worked for me, others did not help as I did have .ts files there

This works well, and for someone who is still getting errors after following the above, just restart your IDE and that shall fix the error.

This is the best answer, since it describes more in depth why the issue occurs (specific reference to tsconfig.json) and includes the case where the editor is bugging out. +1

In my case adding the rootDir attribute worked to get ride of the error. VS2022 + Micorosoft.TypeScript.MSBuild 4.6.4. tsconfig.json in root of ASP.NET Core Web Project. Incude, exclude, typeRoots Attributes where already there and the error kept on comming, until rootDir was added.

Related Topics
json
asp.net-core
visual-studio-2015
typescript

Mentions
Community
Dharman
Double Beep
Sammy
Tagc
Corey Cole
Big Rich
Gru
Cosmin
Danilo
Pran Kumar Sarkar
Tree And Leaf
Rood
F Disk
Mostafa Saadatnia
Susampath
Rubbel Die Katz
Frosty Dog
Matt Parkins
Bakhtiiar Muzakparov
Nico Juicy
Rajat Kumar
Elroy Flynn
Chadiusvt
Desoga
Inukollu Hari Krishna
Rose Specs
Nikhil Nayyar
Tha Brad
Matias Novillo

References
stackoverflow.com/questions/41211566/tsconfig-json-buildno-inputs-were-found-in-config-file

I have an ASP.NET core project and I’m getting this error when I try to build it:

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.json file:

{
  "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?

25 Answers

Add an empty typescript file to the typescript scripts folder (the location of your tsconfig file) to satisfy the typescript compiler.

You can also try to restart your code editor. That works well too.

This can occur because typescript server can’t find any files described by the include array:

// tsconfig.json
{
  //...
  "include": [
    "./src/"
  ],
}

If you’re using VSCode, you can restart your TS server within your editor super easily to prompt it to re-evaluate the file like this:

  1. Navigate to any .ts or .tsx file

  2. Open the command palette (CMD + SHIFT + P on mac)

  3. Run the TypeScript: Restart TS server command:

    TypeScript - Restart TS Server

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:

{
  "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" ]
}

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.

When you create the tsconfig.json file by tsc --init, then it comments the input and output file directory. So this is the root cause of the error.

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.

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

Please note that you need to specify the location of your .ts scripts in rootDir.

I have all of my .ts files inside a src folder that is a sibling of my tsconfig.json. I was getting this error when my include looked like this (it was working before, some dependency upgrade caused the error showing up):

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

changing it to this fixed the problem for me:

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

I was getting this error:

No inputs were found in config file ‘tsconfig.json’.

Specified include paths were '["**/*"]' and exclude paths '["**/*.spec.ts","app_/**/*.ts","**/*.d.ts","node_modules"]'.

I had a .tsconfig file, which read TS files from the ./src folder.

The issue here was that with the source folder not containing any .ts files and I was 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.

"outDir"

Should be different from

"rootDir"

example

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

Changing index.js to index.ts fixed this error for me. (I did not have any .ts files before this).

Note: remember to change anywhere you reference index.js to index.ts except of course, where you reference your main file. By convention this is probably in your lib or dist folders.
My tsconfig.json:

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

My outDir is ./dist so I reference my main in my package.json as "main": "dist/index.js"

enter image description here

I added the following in the root ( visual studio )

{
  "compilerOptions": {
    "allowJs": true,
    "noEmit": true,
    "module": "system",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "include": [
    "**/*"
  ],
  "exclude": [
    "assets",
    "node_modules",
    "bower_components",
    "jspm_packages"
  ],
  "typeAcquisition": {
    "enable": true
  }
}

add .ts file location in ‘include’ tag then compile work fine. ex.

"include": [
"wwwroot/**/*" ]

When using Visual Studio Code, building the project (i.e. pressing Ctrl + Shift + B), moves your .ts file into the .vscode folder (I don’t know why it does this), then generates the TS18003 error.
What I did was move my .ts file out of the .vscode folder, back into the root folder and build the project again.

The project built successfully!

If you don’t want TypeScript compilation, disable it in your .csproj file, according to this post.

Just add the following line to your .csproj file:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

Btw, just had the same problem.

If you had my case, then you probably have the tsconfig.json not in the same directory as the .ts file.

(In my case I stupidly had next to launch.json and tasks.json inside the .vscode folder :P)

I had existing tsconfig files for 4 existing projects in my solution. After upgrading to vs2017 I experienced this problem. It was fixed by adding the (supposedly default) include and exclude sections to the files, as described by NicoJuicy.

For anyone experiencing the same error should try adding «node modules» to the exclude options

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

I have a tsconfig.json file that doesn’t apply to any .ts files. It’s in a separate folder. Instead I only use it as a base for other tsconfig files via "extends": "../Configs/tsconfig.json". As soon as I renamed the base config file to something else e.g. base-tsconfig.json (and updated the extends statements) the error went away and the extending still worked.

I got the same error and in my case it was because vscode couldn’t recognize .ts file.

It was seeing it as text file and I had to rename it to remove one letter and add it back to make it work.

I ran into this issue constantly while packing my projects into nugets via Visual Studio 2019. After looking for a solution for ages I seem to have solved this by following advice in this article

MSBuild & Typescript

especially part about <TypeScriptCompile /> where I included all my .ts resources with the Include operator and excluded others such as node_modules with the Remove operator. I then deleted the tsconfig.json file in each offending project and the nuget packages were generated and no more errors

I received this same error when I made a backup copy of the node_modules folder in the same directory. I was in the process of trying to solve a different build error when this occurred. I hope this scenario helps someone. Remove the backup folder and the build will complete.

I had the same error because I had this:

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

The error appear because the folder wwwroot appear in include and exclude, you should quit one of them.

You need to have the root index.tsx or index.ts file for the

tsc command to work.

У меня есть основной проект 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/*"
  ]
}

Является ли это ошибкой или я делаю что-то неправильно? Недавно я обновил Visual Studio 2015 для обновления 3. Кто-нибудь сталкивался с этим раньше?

4b9b3361

Ответ 1

Добавьте пустой файл машинописного текста в папку сценариев машинописного текста (расположение вашего файла tsconfig), чтобы он соответствовал компилятору машинописного текста.

Ответ 2

Я вообще не использую 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" ]
}

Ответ 3

Я получаю эту ошибку: «Входные данные не найдены в конфигурационном файле» tsconfig.json «. Указанные» include «пути были '["**/*"]' а пути» exclude «были '["**/*.spec.ts","app_/**/*.ts","**/*.d.ts","node_modules"]'.

У меня есть файл .tsconfig, который читает файлы TS из папки «./src».

Проблема здесь заключается в том, что исходная папка не содержит .ts файлы, и я запускаю tslint. Я решил проблему, удалив задачу tslint из моего файла gulp. Поскольку у меня нет файлов .ts для компиляции и печати. Моя проблема решается с помощью этого.

Ответ 4

добавьте расположение файла .ts в тег ‘include’, затем выполните компиляцию. ех.

"include": [
"wwwroot/**/*" ]

Ответ 5

Вы также можете попробовать перезапустить ваш редактор кода. Это тоже хорошо работает.

Ответ 6

При использовании кода Visual Studio, создавая проект (например, нажав Ctrl + Shift + B), перемещает ваш файл .ts в папку .vscode (я не знаю, почему он это делает), затем генерирует ошибку TS18003.
Я сделал перенос моего файла .ts из папки .vscode, обратно в корневую папку и снова создав проект. p >

Проект построен успешно!

Ответ 7

Я добавил следующее в корневую (visual studio)

{
  "compilerOptions": {
    "allowJs": true,
    "noEmit": true,
    "module": "system",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "include": [
    "**/*"
  ],
  "exclude": [
    "assets",
    "node_modules",
    "bower_components",
    "jspm_packages"
  ],
  "typeAcquisition": {
    "enable": true
  }
}

Ответ 8

Когда вы создаете файл tsconfig.json помощью tsc --init, он комментирует каталог файлов ввода и вывода. Так что это коренная причина ошибки.

Чтобы обойти проблему, раскомментируйте эти две строки:

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

Изначально это будет выглядеть выше после отмены комментариев.

Но все мои скрипты .ts были внутри папки src. Итак, я указал /src.

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

Обратите внимание, что вам нужно указать расположение ваших скриптов .ts в rootDir.

Ответ 9

У меня были существующие файлы tsconfig для 4 существующих проектов в моем решении. После обновления до vs2017 я столкнулся с этой проблемой. Он был исправлен путем добавления в файлы (предположительно по умолчанию) include и exclude, как описано NicoJuicy.

Ответ 10

У меня есть все мои .ts файлы в папке src которая является родственной из моего tsconfig.json. Я получал эту ошибку, когда мое include выглядело следующим образом (раньше оно работало, при некотором обновлении зависимости возникла ошибка):

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

изменив это, я решил эту проблему:

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

Ответ 11

Btw, просто была та же проблема.

Если у вас был мой случай, у вас, вероятно, есть tsconfig.json не в том же каталоге, что и файл .ts.

(В моем случае я тупо был рядом с launch.json и tasks.json внутри папки .vscode: P)

Ответ 12

Если вам не нужна компиляция TypeScript, отключите ее в своем файле .csproj, согласно этому посту.

Просто добавьте следующую строку в ваш файл .csproj:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>

Ответ 13

У меня есть файл tsconfig.json, который не применяется ни к каким файлам .ts. Это в отдельной папке. Вместо этого я использую его только как основу для других файлов tsconfig через "extends": "../Configs/tsconfig.json". Как только я переименовал базовый конфигурационный файл во что-то другое, например, base-tsconfig.json (и обновил операторы extends), ошибка исчезла, и расширение все еще работало.

Ответ 14

Мне пришлось добавить элемент files в файл tsconfig.json, например так:

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

Более подробная информация здесь: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

У меня есть основной проект 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/*"
  ]
}

Это ошибка или я что-то не так делаю? Я недавно обновил Visual Studio 2015 до обновления 3. Кто-нибудь сталкивался с этим раньше?

19 ответов

Лучший ответ

Добавьте пустой файл машинописного текста в папку сценариев машинописного текста (местоположение вашего файла tsconfig), чтобы удовлетворить требования компилятора машинописного текста.


253

Community
21 Июн 2018 в 09:34

Я вообще не использую 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" ]
}


21

TreeAndLeaf
21 Авг 2017 в 06:19

Если у вас есть массив include (на что, вероятно, жалуется линтер TypeScript):

Tsconfig.json

{
  ...
  "include": [
    "./src/"
  ],
}

И вы используете VSCode, вы можете очень легко перезапустить сервер TS в своем редакторе, чтобы он попросил его повторно оценить файл.

CMD + SHIFT + P (на Mac) откроет командную строку, а затем найдет команду TypeScript: Restart TS server

enter image description here


20

FrostyDog
14 Фев 2020 в 22:00

Когда вы создаете файл tsconfig.json с помощью tsc --init, он комментирует каталог входных и выходных файлов. Так что это основная причина ошибки.

Чтобы обойти проблему, раскомментируйте эти две строки:

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

Изначально после комментирования это будет выглядеть так, как указано выше.

Но все мои сценарии .ts были внутри папки src. Итак, я указал / src.

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

Обратите внимание, что вам необходимо указать расположение ваших сценариев .ts в rootDir.


9

Pran Kumar Sarkar
7 Июл 2019 в 17:23

Я получаю эту ошибку: «В файле конфигурации ‘tsconfig.json’ входных данных не обнаружено. Указанные пути включения были '["**/*"]', а пути исключения — '["**/*.spec.ts","app_/**/*.ts","**/*.d.ts","node_modules"]'.

У меня есть файл .tsconfig, который читает файлы ts из папки «./src».

Проблема здесь в том, что исходная папка не содержит файлов .ts, и я запускаю tslint. Я решил проблему, удалив задачу tslint из моего файла gulp. Поскольку у меня нет файлов .ts для компиляции и линтинга. Моя проблема решена этим.


6

Jeremy
14 Янв 2019 в 19:32

При использовании кода Visual Studio сборка проекта (т. Е. Нажатие Ctrl + Shift + B ) перемещает ваш < strong> .ts в папку .vscode (я не знаю, почему он это делает), а затем генерирует ошибку TS18003 . Я переместил свой файл .ts из папки .vscode обратно в корневую папку и заново построил проект.

Проект построен успешно!


3

Randell Lamont
1 Июл 2017 в 22:24

Кстати, была такая же проблема.

Если у вас был мой случай, то, вероятно, у вас tsconfig.json находится не в том же каталоге, что и файл .ts.

(В моем случае я тупо имел рядом с launch.json и tasks.json внутри папки .vscode: P)


1

Tha Brad
3 Ноя 2017 в 11:27

Если вам не нужна компиляция TypeScript, отключите ее в своем файле .csproj согласно этой публикации.

Просто добавьте следующую строку в свой файл .csproj:

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>


1

RubbelDieKatz
22 Окт 2018 в 10:02

У меня есть файл tsconfig.json, который не применяется ни к каким файлам .ts. Это в отдельной папке. Вместо этого я использую его только как основу для других файлов tsconfig через "extends": "../Configs/tsconfig.json". Как только я переименовал базовый файл конфигурации во что-то другое, например base-tsconfig.json (и обновил операторы extends) ошибка исчезла, а расширение все еще работало.


0

user764754
18 Мар 2019 в 09:54

Я получил ту же ошибку, когда сделал резервную копию папки node_modules в том же каталоге. Когда это произошло, я пытался решить другую ошибку сборки. Надеюсь, этот сценарий кому-то поможет. Удалите папку резервного копирования, и сборка будет завершена.


0

chadiusvt
24 Июл 2020 в 14:19

Я получил ту же ошибку, и в моем случае это было потому, что vscode не мог распознать файл .ts.

Он видел его как текстовый файл, и мне пришлось переименовать его, чтобы удалить одну букву и добавить обратно, чтобы она работала.


0

Bakhtiiar Muzakparov
12 Дек 2019 в 06:58

"outDir"

Должно отличаться от

"rootDir"

Пример

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


1

FDisk
1 Мар 2020 в 18:11

В моем решении были существующие файлы tsconfig для 4 существующих проектов. После обновления до vs2017 у меня возникла эта проблема. Это было исправлено добавлением (предположительно по умолчанию) разделов включения и исключения в файлы, как описано NicoJuicy.


1

Elroy Flynn
21 Ноя 2017 в 03:27

Я добавил следующее в корень (визуальная студия)

{
  "compilerOptions": {
    "allowJs": true,
    "noEmit": true,
    "module": "system",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  },
  "include": [
    "**/*"
  ],
  "exclude": [
    "assets",
    "node_modules",
    "bower_components",
    "jspm_packages"
  ],
  "typeAcquisition": {
    "enable": true
  }
}


3

NicoJuicy
9 Ноя 2017 в 19:43

У меня все мои файлы .ts находятся в папке src, которая является родственником моего tsconfig.json. Я получал эту ошибку, когда мой include выглядел следующим образом (раньше он работал, некоторое обновление зависимостей вызывало ошибку):

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

Изменив его на это, я решил проблему:

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


4

Corey Cole
1 Авг 2018 в 20:40

Добавьте местоположение файла .ts в тег ‘include’, а затем скомпилируйте работу. напр.

"include": [
"wwwroot/**/*" ]


4

Rajat Kumar
13 Дек 2017 в 17:24

Если вы используете код vs для редактирования, попробуйте перезапустить редактор. Этот сценарий устранил мою проблему. Я думаю, это проблема с кешем редактора.


12

Susampath
17 Фев 2020 в 11:53

Вы также можете попробовать перезапустить редактор кода. Это тоже хорошо работает.


65

desoga
23 Авг 2019 в 16:23

Понравилась статья? Поделить с друзьями:
  • Error ts18002 the files list in config file tsconfig json is empty
  • Error ts1345 an expression of type void cannot be tested for truthiness
  • Error ts1192 module fs has no default export
  • Error ts1086 an accessor cannot be declared in an ambient context
  • Error ts1056 accessors are only available when targeting ecmascript 5 and higher