angular prod build 给 ng2-daterangepicker 插件错误
angular prod build giving error for ng2-daterangepicker plugin
我在构建产品时遇到 ng2-daterangepicker 问题。
ERROR NullInjectorError: StaticInjectorError(AppModule)[DaterangepickerComponent -> DaterangepickerConfig]:
StaticInjectorError(Platform: core)[DaterangepickerComponent -> DaterangepickerConfig]:
NullInjectorError: No provider for DaterangepickerConfig!
at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (http://localhost:9000/main.1c670d3f26f8f3342a59.js:28824:25)
at resolveToken (http://localhost:9000/main.1c670d3f26f8f3342a59.js:40016:24)
at tryResolveToken (http://localhost:9000/main.1c670d3f26f8f3342a59.js:39960:16)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (http://localhost:9000/main.1c670d3f26f8f3342a59.js:39862:20)
at resolveToken (http://localhost:9000/main.1c670d3f26f8f3342a59.js:40016:24)
at tryResolveToken (http://localhost:9000/main.1c670d3f26f8f3342a59.js:39960:16)
at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (http://localhost:9000/main.1c670d3f26f8f3342a59.js:39862:20)
at resolveNgModuleDep (http://localhost:9000/main.1c670d3f26f8f3342a59.js:48299:29)
at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (http://localhost:9000/main.1c670d3f26f8f3342a59.js:48974:16)
at resolveDep (http://localhost:9000/main.1c670d3f26f8f3342a59.js:49346:45)
插件在本地和开发版本中工作,但在生产版本中不工作
Angular 详情:
Angular CLI: 8.3.29
Node: 10.16.0
OS: win32 x64
Angular: 8.2.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.803.29
@angular-devkit/build-angular 0.803.29
@angular-devkit/build-optimizer 0.803.29
@angular-devkit/build-webpack 0.803.29
@angular-devkit/core 8.3.29
@angular-devkit/schematics 8.3.29
@angular/cdk 8.2.3
@angular/cli 8.3.29
@angular/material 8.2.3
@ngtools/webpack 8.3.29
@schematics/angular 8.3.29
@schematics/update 0.803.29
rxjs 6.4.0
typescript 3.5.3
webpack 4.39.2
我遇到了完全相同的问题。
通过在声明您的 Daterangepicker
的模块中的 providers 下导入 DaterangepickerConfig 来修复它
编辑:还必须添加:@import '~ng2-daterangepicker/assets/daterangepicker.css';样式 .css
我在构建产品时遇到 ng2-daterangepicker 问题。
ERROR NullInjectorError: StaticInjectorError(AppModule)[DaterangepickerComponent -> DaterangepickerConfig]: StaticInjectorError(Platform: core)[DaterangepickerComponent -> DaterangepickerConfig]: NullInjectorError: No provider for DaterangepickerConfig! at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (http://localhost:9000/main.1c670d3f26f8f3342a59.js:28824:25) at resolveToken (http://localhost:9000/main.1c670d3f26f8f3342a59.js:40016:24) at tryResolveToken (http://localhost:9000/main.1c670d3f26f8f3342a59.js:39960:16) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (http://localhost:9000/main.1c670d3f26f8f3342a59.js:39862:20) at resolveToken (http://localhost:9000/main.1c670d3f26f8f3342a59.js:40016:24) at tryResolveToken (http://localhost:9000/main.1c670d3f26f8f3342a59.js:39960:16) at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (http://localhost:9000/main.1c670d3f26f8f3342a59.js:39862:20) at resolveNgModuleDep (http://localhost:9000/main.1c670d3f26f8f3342a59.js:48299:29) at NgModuleRef_.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef_.get (http://localhost:9000/main.1c670d3f26f8f3342a59.js:48974:16) at resolveDep (http://localhost:9000/main.1c670d3f26f8f3342a59.js:49346:45)
插件在本地和开发版本中工作,但在生产版本中不工作
Angular 详情:
Angular CLI: 8.3.29 Node: 10.16.0 OS: win32 x64 Angular: 8.2.14 ... animations, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Package Version ----------------------------------------------------------- @angular-devkit/architect 0.803.29 @angular-devkit/build-angular 0.803.29 @angular-devkit/build-optimizer 0.803.29 @angular-devkit/build-webpack 0.803.29 @angular-devkit/core 8.3.29 @angular-devkit/schematics 8.3.29 @angular/cdk 8.2.3 @angular/cli 8.3.29 @angular/material 8.2.3 @ngtools/webpack 8.3.29 @schematics/angular 8.3.29 @schematics/update 0.803.29 rxjs 6.4.0 typescript 3.5.3 webpack 4.39.2
我遇到了完全相同的问题。 通过在声明您的 Daterangepicker
的模块中的 providers 下导入 DaterangepickerConfig 来修复它编辑:还必须添加:@import '~ng2-daterangepicker/assets/daterangepicker.css';样式 .css