1

I am following Angular js tutorial from https://angular.io/guide/quickstart

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"

Here is my folder structure:

Image

3
  • have you check this part angular.io/docs/ts/latest/quickstart.html#add-index-html- ? Commented Dec 5, 2015 at 16:32
  • @PankajParkar is it related to this error ? Commented Dec 5, 2015 at 16:44
  • as a workaround, you can put a path in front thus ../typings/angular2/angular2 Commented Dec 5, 2015 at 17:38

1 Answer 1

1

tsd for angular2 does not actually create the typings file in your typings directory instead it needs to be installed using node:

npm install -save angular2

Then in your tsdconfig.json, you need to enable node module resolution under compilerOptions:

"moduleResolution": "node"
Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for quick response. I placed tsconfig.json to root but getting different error prntscr.com/9anlzk. my tsconfig file look like this: prntscr.com/9anmn1
I think it shouldn't be under wwwroot either, just under the project root at the same level as project.json. This is my project structure imgur.com/gV1QLLv
that didnt work either. I started getting cannot find module "angular2/angular" Please check this prntscr.com/9anwyq. by the way I am not using gulpfile.
Can you move the typings folder into the root as well? The idea is that your scripts/tsd/intermediate files go into the root of the project and the build transpiles to js and the js goes into the wwwroot which is what you deploy.
this didnt help. Please have a look at dropbox.com/s/dgdibivnl4c55vf/Angular2Typescript.rar?dl=0. By the way I am using beta 8. Please have a look at prntscr.com/9ax6gx
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.