1

My component file contains:

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: `<user></user>
  `,
})
export class AppComponent  {

}

My app.modules :

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angluar/forms';
import { AppComponent }  from './app.component';
import { UserComponent } from './components/user.component';

@NgModule({
  imports:      [ BrowserModule ,FormsModule],
  declarations: [ AppComponent, UserComponent],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

when i try to compile my code i got this error : error TS2307: Cannot find module 'angular2/forms' Thanks!

6
  • please add your package.json file, I think you're just missing @angular/forms as dependency. Commented Apr 4, 2017 at 13:42
  • His already existing in package.json Commented Apr 4, 2017 at 13:49
  • Are you using angular-cli? webpack or system.js? is the folder "forms" present in "node_modules/@angular"? Commented Apr 4, 2017 at 13:50
  • did you installed it ? npm install @angular/forms --save Commented Apr 4, 2017 at 13:51
  • the foldar is present in node_modules/@angular Commented Apr 4, 2017 at 14:05

2 Answers 2

2

You have a typo in angular:

import { FormsModule } from '@angluar/forms';

should be:

import { FormsModule } from '@angular/forms';
Sign up to request clarification or add additional context in comments.

1 Comment

PS. I assume you have written the error message longhand, as angular is correctly spelled there ;)
-1

You have errors in your code
check the new one here:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';
import { AppComponent }  from './app.component';
import { UserComponent } from './components/user.component';

@NgModule({
  imports:      [ BrowserModule ,FormsModule],
  declarations: [ AppComponent, UserComponent],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

2 Comments

eeh, how is this different from my answer? :D You just made the same change as I pointed out ;)
what a coincidence!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.