Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical bug!!! Uncaught Error: StaticInjectorError[CacheStorageAbstract]: StaticInjectorError[CacheStorageAbstract]: NullInjectorError: No provider for CacheStorageAbstract! #3

Open
optimistex opened this issue Dec 18, 2017 · 2 comments

Comments

@optimistex
Copy link

Can not build a project with the component!
When I build that ng build --prod I have the error in a browser's console:

Uncaught Error: StaticInjectorError[function (){}]: 
  StaticInjectorError[function (){}]: 
    NullInjectorError: No provider for function (){}!
    at e.get (main.a8cc9c5b546e8168adc3.bundle.js:1)
    at main.a8cc9c5b546e8168adc3.bundle.js:1
    at g (main.a8cc9c5b546e8168adc3.bundle.js:1)
    at e.get (main.a8cc9c5b546e8168adc3.bundle.js:1)
    at main.a8cc9c5b546e8168adc3.bundle.js:1
    at g (main.a8cc9c5b546e8168adc3.bundle.js:1)
    at e.get (main.a8cc9c5b546e8168adc3.bundle.js:1)
    at gt (main.a8cc9c5b546e8168adc3.bundle.js:1)
    at main.a8cc9c5b546e8168adc3.bundle.js:1
    at vt (main.a8cc9c5b546e8168adc3.bundle.js:1)

Detail info about the problem
Build with --aot:

$ ng serve --aot
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2017-12-18T15:49:11.559Z                                                            
Hash: bc504e54a57fdb5a1683
Time: 48230ms
chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 5.3 MB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 1.14 MB [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 915 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 28.5 MB [initial] [rendered]

webpack: Compiled successfully.

Catch the error in a browser:

Uncaught Error: StaticInjectorError[CacheStorageAbstract]: 
  StaticInjectorError[CacheStorageAbstract]: 
    NullInjectorError: No provider for CacheStorageAbstract!
    at _NullInjector.get (core.js:993)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.get (core.js:1094)
    at resolveToken (core.js:1281)
    at tryResolveToken (core.js:1223)
    at StaticInjector.get (core.js:1094)
    at resolveNgModuleDep (core.js:10878)
    at _createClass (core.js:10915)
    at _createProviderInstance$1 (core.js:10889)

My system:

$ ng -v

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.6.1
Node: 9.3.0
OS: linux x64
Angular: 5.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.6.1
@angular-devkit/build-optimizer: 0.0.36
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.42
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.1
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.10.0
@optimistex
Copy link
Author

The bug fixed with code:

import {CacheService} from 'ng2-cache-service';
import {CacheStorageAbstract} from "ng2-cache-service/dist/src/services/storage/cache-storage-abstract.service";
import {CacheMemoryStorage} from "ng2-cache-service/dist/src/services/storage/memory/cache-memory.service";

@NgModule({
    providers: [
        CacheService,
        {provide: CacheStorageAbstract, useClass: CacheMemoryStorage},
    ],
})
export class CoreModule {
}        

I think you need update the README.md.

@sunilpes
Copy link

sunilpes commented Jun 5, 2018

@optimistex U have saved my day! After hours of scratching my head, I have found this thread.
This issue is not appearing in normal build but when AOT is set. Really appreciate it. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants