TS2307: Cannot find module 'angular2/core' while importing Angular2 on TypeScript

前端 未结 8 1631
庸人自扰
庸人自扰 2021-01-31 03:39

Hi I have a lil bit of Angular 1 background, I am learning Angular 2.

for starting up with Angular 1, only dependency is to add the angular sources either the angu

8条回答
  •  长发绾君心
    2021-01-31 03:52

    Do this in index.html:

    
    
    
        
    
    
    
        Loading....
    
    
    
    
    
    
        
    
    
    
    

    try using this your first component:

    import {Component} from 'angular2/core';
    import {bootstrap} from 'angular2/platform/browser';
    
    @Component({
        selector: 'app',
        template: "Hello"
    })
    export class App{  
        constructor(){ }    
    }
    
    bootstrap(App); 
    

    your Index.html file has missing alot. like importing main component using system.js. i.e System.import('App');

    tsconfig.json:

    {
      "version": "1.5.3",
      "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": true,
        "noImplicitAny": false
      }
    }
    

提交回复
热议问题