2016-07-22 85 views
1

我学习了angular2。安装了node.js,npm,typescript。Angular2 - app/my-component.component.ts(1,25):错误TS2307:无法找到模块'angular2/core'

我跑npm start

显示错误:

app/my-component.component.ts(1,25): error TS2307: Cannot find module 'angular2/core'. 

我-component.component.ts

import {Component} from "angular2/core"; 

@Component({ 
    selector: 'my-component', 
    template: ` 
     This is my component! 
    ` 
}) 
export class MyComponentComponent { 

} 

的index.html

<html> 
    <head> 
    <title>Angular 2 QuickStart</title> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="styles.css"> 

    <!-- Polyfill(s) for older browsers --> 
    <script src="node_modules/core-js/client/shim.min.js"></script> 

    <script src="node_modules/zone.js/dist/zone.js"></script> 
    <script src="node_modules/reflect-metadata/Reflect.js"></script> 
    <script src="node_modules/systemjs/dist/system.src.js"></script> 

    <script src="systemjs.config.js"></script> 
    <script> 
     System.import('app').catch(function(err){ console.error(err); }); 
    </script> 
    </head> 

    <body> 
    <my-app>Loading...</my-app> 
    </body> 
</html> 

我不能undestand为什么不能找到angular2/core? 你能帮请

回答

0

使用

@angular/core 

反而会解决这个错误。
希望这会帮助你。

+0

是的。工作。但为什么不使用“angular2/core”?我从文档 – Dmitrij

+0

复制因为包含模块的导向名称已更改。但我不知道这是变了。 – mgmg

相关问题