Angular 未找到ngx引导模块:错误:Can';t解决';ngx引导/加载程序&x27;

Angular 未找到ngx引导模块:错误:Can';t解决';ngx引导/加载程序&x27;,angular,angular-cli,ngx-bootstrap,Angular,Angular Cli,Ngx Bootstrap,我用的是ngx的datepicker-bootstrap@3.2.0在一个有角度的6.1.10项目中。 我还加载了一个不同的区域设置(nlLocale) 在我的功能模块中: import { defineLocale, nlLocale, BsDatepickerModule, BsLocaleService} from 'ngx-bootstrap'; defineLocale('nl', nlLocale); 在我的组件中: import { BsLocaleService } from

我用的是ngx的datepicker-bootstrap@3.2.0在一个有角度的6.1.10项目中。 我还加载了一个不同的区域设置(nlLocale)

在我的功能模块中:

import { defineLocale, nlLocale, BsDatepickerModule, BsLocaleService} from 'ngx-bootstrap';

defineLocale('nl', nlLocale);
在我的组件中:

import { BsLocaleService } from 'ngx-bootstrap';
export class MyComponent implements OnInit {  
  locale = 'nl';

  constructor(private bsLocaleService: BsLocaleService) {
    this.bsLocaleService.use(this.locale);
  }
}
当我使用命令生成此文件时:

ng build --watch
我没有问题,我可以运行应用程序,使用日期选择器,月份以荷兰语显示

但是,当我为生产而构建时:

ng build --prod 
我得到以下错误:
/node_modules/ngx bootstrap/datepicker/fesm5/ngx-bootstrap-datepicker.js中的错误 未找到模块:错误:无法解析“E:\MyProject\node\u modules\ngx bootstrap\datepicker\fesm5”中的“ngx引导/加载程序” ./node_modules/ngx bootstrap/modal/fesm5/ngx-bootstrap-modal.js中出错 未找到模块:错误:无法解析“E:\MyProject\node\U modules\ngx bootstrap\modal\fesm5”中的“ngx引导/加载程序”

我已经查找了“fesm5”中存在的文件“ngx bootstrap datepicker.js”,但在该文件中没有看到与ngx bootstrap/loader相关的任何引用

我试着降级到ngx-bootstrap@3.0.1它确实起作用,所以它显然表明ngx引导有问题,但从一些我一直在做的阅读来看,其他人似乎没有这个问题


以前有人见过这个吗

您是否在功能模块中完成了以下操作

@NgModule({
  imports: [BsDatepickerModule.forRoot(),...]
})

如果是这样,请尝试将其添加到您的根模块中。我目前正在使用Angular 9和最新版本的ngx引导。 我认为最新的实现是在app.module.ts文件中导入BsDatepickerModule,如下所示

app.module.ts代码中的导入语句:

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
  imports: [
BrowserAnimationsModule,
BsDatepickerModule.forRoot()
import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker';

@Component({ selector: 'app-', templateUrl: './register.component.html', styleUrls: ['./register.component.css'],
})
export class RegisterComponent implements OnInit {


bsConfig: Partial<BsDatepickerConfig>;



constructor() {}

ngOnInit() {

this.bsConfig = Object.assign({}, { containerClass: 'theme-blue' });

}
}
在app.module.ts中导入:

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
  imports: [
BrowserAnimationsModule,
BsDatepickerModule.forRoot()
import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker';

@Component({ selector: 'app-', templateUrl: './register.component.html', styleUrls: ['./register.component.css'],
})
export class RegisterComponent implements OnInit {


bsConfig: Partial<BsDatepickerConfig>;



constructor() {}

ngOnInit() {

this.bsConfig = Object.assign({}, { containerClass: 'theme-blue' });

}
}
]

组件代码:

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
  imports: [
BrowserAnimationsModule,
BsDatepickerModule.forRoot()
import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker';

@Component({ selector: 'app-', templateUrl: './register.component.html', styleUrls: ['./register.component.css'],
})
export class RegisterComponent implements OnInit {


bsConfig: Partial<BsDatepickerConfig>;



constructor() {}

ngOnInit() {

this.bsConfig = Object.assign({}, { containerClass: 'theme-blue' });

}
}
] })

导出类AppModule(){}


尝试了这两种方法,结果相同您可以更新关于模块外观的帖子吗?对于较新版本,导入状态是从“ngx引导/下拉”导入{BsDropdownModule};您可能需要在添加库后重建,还可以使用Angular cli来添加工具,而不是npm,并使用以下命令ng add ngx bootstrap type Ctrl+C来停止应用程序和ng serve——观察重建itI我认为从Angular 6-8开始,您仍然可以遵循旧的实现。最好的策略是在package.json文件中识别ngx引导版本,并在官方网站中找到与您的版本匹配的文档