Cannot find external module 'angular2/angular2' - Angular2 w/ Typescript

前端 未结 10 1313
臣服心动
臣服心动 2020-12-01 21:20

I am going through the step by step tutorial on angular.io (Angular 2). I am using typescript. I get the following error when trying to compile:

Cannot find ex

相关标签:
10条回答
  • 2020-12-01 21:53

    Why is this error occuring?

    make sure you have this file : https://github.com/borisyankov/DefinitelyTyped/blob/master/angular2/angular2.d.ts included in your project (recommend using tsconfig.json : https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md)

    0 讨论(0)
  • 2020-12-01 21:56

    Adding these files to the head will give you the latest working version of Angular2.

    <script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
    <script src="https://jspm.io/system@0.16.js"></script>
    <script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.dev.js"></script>
    

    Source: Angular.io: 5 Minute Quickstart

    0 讨论(0)
  • 2020-12-01 21:56

    If you are running a meteor-angular2 application my solution will help you; simply add the below line into your typescript app.ts before import statements:

    /// <reference path="typings/angular2-meteor/angular2-meteor.d.ts" />
    
    0 讨论(0)
  • 2020-12-01 21:57

    The TypeScript Definition (TSD) for Angular2 is missing:

     - cd src               //go to the directory where your ts-file is
     - tsd install angular2 //load Angular2 TypeScript Definition
    

    Then compile again (e.g. tsc -p src -w)

    If tsd fails install it first:

    npm install -g tsd@^0.6.0
    
    0 讨论(0)
提交回复
热议问题