找不到ngx-bootstrap模块:错误:无法解析'ngx-bootstrap / loader'

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

我在Angular 6.1.10项目中使用了[email protected]中的datepicker。我还加载了一个不同的语言环境(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

我没有问题,我可以运行应用程序,使用datepicker,月份以荷兰语显示。

但是,当我为生产而建立:

ng build --prod 

我收到以下错误: ./node_modules/ngx-bootstrap/datepicker/fesm5/ngx-bootstrap-datepicker.js中的错误找不到模块:错误:无法解析'E:\ MyProject \ node_modules \ ngx-bootstrap中的'ngx-bootstrap / loader' \ datepicker \ fesm5'ERROR in ./node_modules/ngx-bootstrap/modal/fesm5/ngx-bootstrap-modal.js找不到模块:错误:无法解析'E:\ MyProject \'中'ngx-bootstrap / loader' node_modules \ NGX-引导\模式\ fesm5'

我找了'ngx-bootstrap-datepicker.js'文件,该文件存在于'fesm5'中,但我看到文件中没有任何与ngx-bootstrap / loader相关的引用。

我已经尝试降级到[email protected]并且它确实有效,因此它显然表明ngx-bootstrap存在问题,但是从一些阅读中我一直在做其他人似乎没有遇到这个问题。

有没有人遇到过这个?

angular angular-cli ngx-bootstrap
1个回答
0
投票

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

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

如果是这样,请尝试将其添加到根模块中

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