tsc 无法检测 Angular2 RC 定义



我正在使用Angular 2.0.0-rc.1 ,但是正在与Typescript Compiler(Typescript 1.8.10 )挣扎。如果我在项目上运行TSC,我会得到这样的错误:

app/app.component.ts(1,33):错误ts2307:找不到模块'@angular/core'

但是,我以为是因为node_modules/@angular/core中的 package.json具有:

  "typings": "index.d.ts",

index.d.ts提供了定义,情况不应该如此?VSCODE不会突出这些软件包的任何问题,如果我单击导入上的"转到定义",将链接到源。

我该怎么做才能避免这样的编译器错误?

更新:

我的packages.json

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "sourceMap": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": true,
        "noEmitOnError": true
    },
    "exclude": [
        "node_modules",
        "platforms"
    ]
}

在您的tsconfig.json中排除node_modules文件夹

    {
      "compilerOptions": {
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "module": "commonjs",
        "noEmitOnError": true,
        "noImplicitAny": false,
        "removeComments": false,
        "sourceMap": true,
        "target": "es6",
        "moduleResolution": "node",
        "suppressImplicitAnyIndexErrors": true,
        "watch":true
      },
      "compileOnSave": true,
      "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts",
        "typings"
      ]
    }

最新更新