You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Stackblitz中导入angular2-wizard npm模块时出错,求帮助

解决angular2-wizard在Stackblitz中的导入错误

问题场景

已在Stackblitz中安装angular2-wizard npm包,并在test.module.ts中按官方文档导入FormWizardModule,代码如下:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { StripeComponent } from './stripe/stripe.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgxStripeModule } from 'ngx-stripe';
import { FormWizardModule } from 'angular2-wizard';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    FormWizardModule
  ],
  declarations: [StripeComponent],
  exports: [
    StripeComponent
  ]
})
export class TestModule { }

运行后出现模块导入相关错误。

解决方案

  • 版本兼容性问题:angular2-wizard是仅支持Angular 2.x-4.x的老旧库,若你的Stackblitz项目使用Angular 5及以上版本,必然出现兼容性错误。建议替换为维护活跃的替代库,比如ngx-form-wizard或angular-archwizard。
  • 强制使用该库的处理方式:
    1. 修改package.json中Angular核心依赖版本为^4.4.7(包括@angular/core、@angular/common、@angular/forms等)
    2. 重新安装依赖,确保所有依赖版本匹配
  • 基础检查:确认package.json中已正确添加angular2-wizard依赖,导入语句import { FormWizardModule } from 'angular2-wizard';无拼写错误。

内容的提问来源于stack exchange,提问作者chuckd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 00:12:49