0

I am using angular 2.0.0-rc.1, but am struggling with the typescript compiler (Typescript 1.8.10). If I run tsc on my project, I get loads of errors like this:

app/app.component.ts(1,33): error TS2307: Cannot find module '@angular/core'

However, I thought that because the package.json in node_modules/@angular/core has the line:

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

and index.d.ts provides the definitions, this shouldn't be the case? VSCode doesn't highlight any issues with these packages and will link through to the source if I click "Go to Definition" on the imports.

What should I do to avoid compiler errors like this?

Update:

My packages.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "sourceMap": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": true,
        "noEmitOnError": true
    },
    "exclude": [
        "node_modules",
        "platforms"
    ]
}
George Edwards
  • 8,979
  • 20
  • 78
  • 161

1 Answers1

0

In your tsconfig.json exclude node_modules folder

    {
      "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"
      ]
    }
null canvas
  • 10,201
  • 2
  • 15
  • 18