将 ngx-bootstrap 3.0.1 升级到 4.0.1 [英] Upgrading ngx-bootstrap 3.0.1 to 4.0.1

查看:72
本文介绍了将 ngx-bootstrap 3.0.1 升级到 4.0.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 ngx bootstrap 3.0.1 升级到 4.0.1 时出现以下错误.替换了 node_modules,package.json 仍然出现相同的错误.角度版本:

While Upgrading from ngx bootstrap 3.0.1 to 4.0.1 am getting the following error.Replaced the node_modules, package.json still getting the same errors. Angular Version :

Angular 6,
Typescript: 2.7.2.

Errors:
ERROR in node_modules/ngx-bootstrap/chronos/utils/type-checks.d.ts(8,62): error TS2304: Cannot find name 'Extract'.

node_modules/ngx-bootstrap/datepicker/reducer/bs-datepicker.actions.d.ts(5,33): error TS1039: Initializers are not allowed in ambient contexts.

node_modules/ngx-bootstrap/timepicker/reducer/bs-datepicker.actions.d.ts(4,33): error TS1039: Initializers are not allowed in ambient contexts.

图像中的错误

推荐答案

我在Angular中使用ngx-editor实现富文本编辑器时遇到这个错误

I have encounter this error when I was using ngx-editor to implement rich text editor in Angular

此错误是由于旧版本的 Angular 和 rxjs 引起的,在我的情况下,我使用的是 Angular 6 和 rxjs 6.0.0,然后我使用以下命令将其更新为 Angular 7 和 rxjs 6.2.0(Typescript 也将更新到 typescript 2.9.2)

This error occurs due to older version of Angular and rxjs, In my case I was using Angular 6 and rxjs 6.0.0, then I have updated it to Angular 7 and rxjs 6.2.0 by using below commands (Typescript will also be updated to typescript 2.9.2)

ng update rxjs@~6.2.0
ng update @angular/cli @angular/core

注意:如果您收到以下警告

Note: If you are getting below warning

npm 警告 notsup 跳过可选依赖:fsevents@1.2.7 不受支持的平台:想要 {"os":"darwin","arch":"any"}(当前:{"os":"win32","arch":"x64"})

如果你想忽略这个警告 (fsevents@1.2.7:) 你可以使用下面的命令

and you want to ignore this warning (fsevents@1.2.7:) you can use below command

   npm i -f

在此之后,我已经卸载了 ngx-bootstrap 和 ngx-editor,然后首先安装依赖包,然后重新安装 ngx-bootstrap 和 ngx-editor,如下步骤所述.

After this, I have uninstall ngx-bootstrap and ngx-editor, then first install dependency packages and then reinstall ngx-bootstrap and ngx-editor, as mentioned below steps.

npm i ajv@^6.9.1 --save

npm i font-awesome@^4.7.0 --save

npm i angular-font-awesome

npm install ngx-bootstrap --save

npm install ngx-editor --save

最后需要在app.module.ts中检查HttpClientModule等包是否正确导入

At last, you need to check if HttpClientModule and other packages are properly imported in app.module.ts

import { NgxEditorModule } from 'ngx-editor';
import { AngularFontAwesomeModule } from 'angular-font-awesome';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { HttpClientModule } from '@angular/common/http'; 

imports: [
    BrowserModule,
    AppRoutingModule,
    NgxEditorModule,
    AngularFontAwesomeModule,
    TooltipModule.forRoot(),
    HttpClientModule
  ],

现在解决了,另外可以通过ngx-editor使用富文本编辑器

Now it is resolved, In addition you can able to use rich text editor by using ngx-editor

谢谢

这篇关于将 ngx-bootstrap 3.0.1 升级到 4.0.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆