Reputation: 1346
I'm developing an Ionic 2/Angular app and I'm trying to use form validation following this tutorial: https://angular.io/docs/ts/latest/cookbook/dynamic-form.html
But the compiler says:
Cannot find module '@angular/forms'.
Why is this modules not available? Is it deprecated?
Upvotes: 10
Views: 58374
Reputation: 51
Run this command npm install @angular/forms --save
Go to package.json and double check to make sure this dependency is present @angular/forms: "{your version}",
and save the changes.
Close and reopen your IDE and go back to app.module.ts. Remove the import statement and retype it again, then it should work.
Thank You
Upvotes: 3
Reputation: 1948
I had a weird situation where I can not do npm install, and had to copy the libs from shared path. Copy the "forms" folder under node_modules/@angaular solved the issue.
Upvotes: -1
Reputation: 173
Is import { FormsModule } from '@angular/forms'; is injected in app.module.ts and added FormsModule array in the imports as below
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
imports: [
BrowserModule,
FormsModule
]
Upvotes: -3
Reputation: 145880
Sometimes when updating versions I see messages like this:
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'R:\TFS\RRCRM\RRCRM\node_modules\@angular\forms' -> 'R:\TFS\RRCRM\RRCRM\node_modules\@angular\.forms.DELETE'
npm ERR! at Error (native)
npm ERR! { [Error: EPERM: operation not permitted, rename 'R:\TFS\RRCRM\RRCRM\node_modules\@angular\forms' -> 'R:\TFS\RRCRM\RRCRM\node_modules\@angular\.forms.DELETE']
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'rename',
npm ERR! path: 'R:\\TFS\\RRCRM\\RRCRM\\node_modules\\@angular\\forms',
npm ERR! dest: 'R:\\TFS\\RRCRM\\RRCRM\\node_modules\\@angular\\.forms.DELETE',
npm ERR! parent: 'rrcrm' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Please include the following file with any support request:
npm ERR! R:\TFS\RRCRM\RRCRM\npm-debug.log
I belive it can be due to file in use errors sometimes (I'm running Visual Studio on Windows as administrator).
Make sure nothing is running that might have a file lock on any packages - such as angular CLI. So close any windows or processes and run something like npm install
again.
Upvotes: 0
Reputation: 8433
I ran into the same problem, my solution was:
1) add forms to the package.json:
"dependencies": {
...
"@angular/forms": "0.2.0",
...
}
2) install using npm in the console, type within the app folder
npm install
3) run app again
npm start
Hope this helps
Upvotes: 10
Reputation: 631
Try npm install @angular/forms --save
It will warn you that you should be using 2.0.0-rc.4 though. This may come with it's own set of upgrade challenges...
Upvotes: 12