简体   繁体   English

Angular 找不到变量缓存

[英]Angular can't find variable cache

My Angular app works fine on everything when I run it locally, but if I deploy it on Heroku - in a Go server, aot is disabled on angular build on Chrome and Opera - both on mobile, linux and osx - but it throws an error on safari: My Angular app works fine on everything when I run it locally, but if I deploy it on Heroku - in a Go server, aot is disabled on angular build on Chrome and Opera - both on mobile, linux and osx - but it throws an error在 safari 上:

ReferenceError: Can't find variable: Cache

When I have a closer look at the error, I suppose it is from my module providers.当我仔细查看错误时,我想它来自我的模块提供程序。 Because it takes me to:因为它需要我:

 main-es2015[...].js

[...], IP, KM, {
            provide: Cache, // error
            useClass: KM,
            multi: !0
        }],

Corresponding app.module.ts part对应的app.module.ts部分

providers: [
    {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true},
    {provide: HTTP_INTERCEPTORS, useClass: ErrorInterceptorService, multi: true},
    {provide: HTTP_INTERCEPTORS, useClass: CachingInterceptor, multi: true},
    ApplicationStateService,
    CacheMapService,
    {provide: Cache, useClass: CacheMapService, multi: true}
  ],

Cache provider wasn't multi, made it multi but made no difference缓存提供程序不是多的,而是多的,但没有区别

There is a variable named:有一个变量名为:

declare var Cache: {prototype: Cache; new():Cache}

in lib.dom.d.ts file.lib.dom.d.ts文件中。 I was using this variable instead of my cache.ts model.我使用的是这个变量而不是我的cache.ts model。 So silly of me... If you have a cache model too, put this at top of your *.module.ts file我太傻了...如果您也有缓存 model ,请将其放在 *.module.ts 文件的顶部

import {Cache} from 'path-to-cache-file'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM