简体   繁体   English

找不到模块“ angular2 / angular”

[英]cannot find module “angular2/angular”

I am following Angular js tutorial from https://angular.io/guide/quickstart 我正在从https://angular.io/guide/quickstart关注Angular js教程

and I am trying to use this code: 我正在尝试使用以下代码:

import {bootstrap, Component} from 'angular2/angular2';
@Component({
    selector: 'my-app',
    template: '<h1>My First Angular 2 App</h1>'
})
class AppComponent { }
bootstrap(AppComponent);

but I get this error: 但是我得到这个错误:

cannot find module "angular2/angular" 找不到模块“ angular2 / angular”

Here is my folder structure: 这是我的文件夹结构:

图片

tsd for angular2 does not actually create the typings file in your typings directory instead it needs to be installed using node: 针对angular2的tsd实际上并未在您的打字目录中创建打字文件,而是需要使用node安装该文件:

npm install -save angular2

Then in your tsdconfig.json, you need to enable node module resolution under compilerOptions: 然后,在tsdconfig.json中,需要在compilerOptions下启用节点模块解析:

"moduleResolution": "node"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM