VS CODE错误S5057在指定的目录中找不到tsconfig.json文件:'.'

Win*_*cca 11 json visual-studio-code

我正在使用我的角度2启动项目获得视觉工作室代码.

我已经设置了我的tsconfig.json ...

    {
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)

我立即遇到了这个错误

  [ts] Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.
class AppComponent
Run Code Online (Sandbox Code Playgroud)

我无法确定发生了什么,所以我运行了一个构建并得到了这个错误.

error TS5057: Cannot find a tsconfig.json file at the specified directory: '.'
Run Code Online (Sandbox Code Playgroud)

此错误解释了为什么我收到有关组件装饰器的错误,但我不确定为什么找不到tsconfig.json文件.

我只有一个文件夹,它包含除index.html,package.json和.gitignore之外的所有内容.

meD*_*Dev 10

我得到了类似的错误.通过更改tasks.json中的以下行来解决

"args": ["-p", "."],

"args": ["-p", "./src"],

在我的情况下tsconfig.json是在src文件夹中.Angular 2项目是使用angular-cli创建的.


Tra*_*oud 7

对于Visual Studio Code上的大多数人来说,仅使用简单的内容tsconfig.json在文档根目录(可能是您的.ts文件所在位置)中创建文件就足够了:{}.

这意味着"一个空的JSON文件<...>.这对大多数人来说已经足够了."

来源.