将ngx-bootstrap 3.0.1升级到4.0.1

问题描述 投票:2回答:1

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

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.

Errors in the image

angular6 ngx-bootstrap
1个回答
2
投票

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

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

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

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

npm WARN notsup SKIPPING OPTIONAL DEPENDENCY:不支持的[email protected]平台:想要{“os”:“darwin”,“arch”:“any”}(当前:{“os”:“win32”,“arch”: “64”})

并且你想忽略这个警告([email protected] :)你可以使用下面的命令

   npm i -f

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

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和其他包。

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使用富文本编辑器

谢谢


0
投票

此错误的解决方案是更改Bootstrap版本(4.0.0到3.0.0)并删除package.json中的^(即“rxjs”:“^ 6.0.0”到“rxjs”:“6.0.0”,并且“rxjs-compat”:“^ 6.2.2”到“rxjs-compat”:“6.2.2”,)。如果你想要bootstrap 4版本而不是尝试更改rxjs和rxjs-compat(我在上面的行中告知)。并删除node_module和package-lock.json而不是安装npm。

© www.soinside.com 2019 - 2024. All rights reserved.