ngx-masonry
ngx-masonry copied to clipboard
Reference Error: window is not defined Angular 14
ERROR Error: Uncaught (in promise): ReferenceError: window is not defined
ReferenceError: window is not defined
Getting ReferenceError for window
with ssr build.
"@angular/animations": "^14.2.0",
"@angular/cdk": "^14.2.4",
"@angular/common": "^14.2.0",
"@angular/compiler": "^14.2.0",
"@angular/core": "^14.2.0",
"@angular/forms": "^14.2.0",
"@angular/material": "^14.2.4",
"@angular/platform-browser": "^14.2.0",
"@angular/platform-browser-dynamic": "^14.2.0",
"@angular/platform-server": "^14.2.0",
"@angular/router": "^14.2.0",
"@nguniversal/express-engine": "^14.2.0"
"masonry-layout": "^4.2.2",
"ngx-masonry": "^14.0.1"
import { NgxMasonryModule } from 'ngx-masonry';
@NgModule({
declarations: [HomeComponent],
imports: [
NgxMasonryModule,
CommonModule,
AppRoutingModule,
MatButtonModule,
MatIconModule,
MatCardModule,
],
})
export class AppModule {}
Is it not compatible with SSR? or am i missing something
It is works with SSR. Add the following code to "server.ts":
global['window'] = window;
global['document'] = window.document;
still getting same error
I have the same issue with version 14. (With version 13 it works) I added the requested global definitions but I still have the issue