I added SSR Support, but when I run the command: npm run build:ssr && npm run serve:ssr, appears this message, anyone knows why?
1 Answers
0
votes
In your local directories, open /server/main.js and navigate to line 1:4106087 (line 1 column 4106087). You should be able to exactly pinpoint where the error is being thrown.
Put a validation on every place you use Element, such as:
import {isPlatformBrowser} from '@angular/common';
...
constructor(@Inject(PLATFORM_ID) private platformId: number) {}
if (isPlatformBrowser(this.platformId)) {
// Your code here where you access the DOM
}
...

Elementdo you have any results? During SSR there is no DOM and other global objects as in the browser, see the guidelines: sap.github.io/spartacus-docs/… and angular.io/guide/universal#working-around-the-browser-apis - Mirosław Grochowski