Angular 8-错误-找不到模块'@ angular / forms / src / directives / validators

时间:2019-06-10 19:43:32

标签: angular

我安装了新软件包:
npm install --save ngx-cpf-cnpj

现在我收到一条错误消息。

我的package.json

"dependencies": {
"@angular/animations": "~8.0.0",
"@angular/cdk": "^8.0.0",
"@angular/common": "~8.0.0",
"@angular/compiler": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/flex-layout": "^8.0.0-beta.26",
"@angular/forms": "~8.0.0",
"@angular/material": "^8.0.0",
"@angular/platform-browser": "~8.0.0",
"@angular/platform-browser-dynamic": "~8.0.0",
"@angular/router": "~8.0.0",
"hammerjs": "^2.0.8",
"ngx-cpf-cnpj": "^1.0.3",
"ngx-mask": "^7.9.9",
"rxjs": "~6.4.0",
"rxjs-compat": "^6.5.2",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},

错误消息:

ERROR in node_modules/ngx-cpf-cnpj/lib/cpf-cnpj-validator.directive.d.ts(6,38): error TS2307: Cannot find module '@angular/forms/src/directives/validators'.

我该如何解决这个问题?

我没有文件夹node_modules/@angular/forms/src

enter image description here

这是我的app.module.ts,我正在使用FormsModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';    
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MaterialModule} from './material.module';
import {FlexLayoutModule} from '@angular/flex-layout';
...
import {NgxMaskModule} from 'ngx-mask';
import { NgxCpfCnpjModule } from  'ngx-cpf-cnpj';
...
  imports: [
    BrowserModule,
    NgxMaskModule.forRoot(),
    NgxCpfCnpjModule,
    ReactiveFormsModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    FlexLayoutModule,
    FormsModule,
    MaterialModule
  ],

在cpf-cnpj-validator.directive.d.ts内部,有以下行:

import("@angular/forms/src/directives/validators").ValidationErrors;

0 个答案:

没有答案