Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
TranslateCacheModule
✓ import { TranslateCacheModule } from 'ngx-translate-cache';
✗ import { TranslateCacheModule } from '@ngx-translate/cache';
Package name is ngx-translate-cache, not under @ngx-translate scope. ESM-only, no CommonJS.
TranslateCacheService
✓ import { TranslateCacheService } from 'ngx-translate-cache';
✗ const TranslateCacheService = require('ngx-translate-cache').TranslateCacheService;
ESM-only since v20; require() throws ERR_REQUIRE_ESM.
TranslateCacheSettings
✓ import { TranslateCacheSettings } from 'ngx-translate-cache';
✗ import { TranslateCacheSettings } from 'ngx-translate-cache/settings';
All exports from package root; no subpath exports.
Shows setup of AppModule with TranslateCacheModule.forRoot() with AoT-compatible factory and component initialization calling cache.init().
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { TranslateCacheModule, TranslateCacheSettings, TranslateCacheService } from 'ngx-translate-cache';
import { AppComponent } from './app.component';
export function TranslateCacheFactory(translateService: TranslateService, translateCacheSettings: TranslateCacheSettings) {
return new TranslateCacheService(translateService, translateCacheSettings);
}
@NgModule({
imports: [
BrowserModule,
TranslateModule.forRoot(),
TranslateCacheModule.forRoot({
cacheService: {
provide: TranslateCacheService,
useFactory: TranslateCacheFactory,
deps: [TranslateService, TranslateCacheSettings]
}
})
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
// In component:
import { Component } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { TranslateCacheService } from 'ngx-translate-cache';
@Component({ selector: 'app', template: '{{ "HELLO" | translate }}' })
export class AppComponent {
constructor(translate: TranslateService, cache: TranslateCacheService) {
translate.setDefaultLang('en');
cache.init();
translate.use('en');
}
}
Errors
Common errors & fixes
Error: Can't resolve 'ngx-translate-cache'
Package not installed or wrong version.
fixRun 'npm install ngx-translate-cache@20 --save' and verify node_modules contains the package.
Error: require() of ES Module /node_modules/ngx-translate-cache/index.mjs not supported
Using CommonJS require() to load an ESM-only module.
fixChange to ESM import syntax: 'import { TranslateCacheService } from 'ngx-translate-cache';' or set 'type': 'module' in package.json. NullInjectorError: No provider for TranslateCacheService!
TranslateCacheService not provided via TranslateCacheModule.forRoot().
fixEnsure AppModule imports TranslateCacheModule.forRoot({cacheService:...}) with factory as shown in docs. Error: The pipe 'translate' could not be found
TranslateModule not imported or not properly configured.
fixImport TranslateModule.forRoot() in AppModule and add to imports.
Audit
Dependencies
@angular/commonrequiredpeer dep for Angular 20
@angular/corerequiredpeer dep for Angular 20
@ngx-translate/corerequiredpeer dep >=14.0.0, core translation functionality