Having upgraded my Angular 13 app to version 14, I encountered an issue where the page no longer loads properly. Despite checking the configuration and stripping down the index.html file to its basics, the issue persists - nothing seems to be working.
Upon running 'ng serve' after building the project, I received the following error:
${sourceUrl}`;:279484 Uncaught SyntaxError: Strict mode code may not include a with statement (at ${sourceUrl}`;:279484:5)
I have been unable to pinpoint the source of this error.
Here is a snippet from my main.ts file:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { enableProdMode } from '@angular/core';
const providers = [
{ provide: 'BASE_URL', useFactory: getBaseUrl, deps: [] }
];
if (environment.production) {
enableProdMode();
}
export function getBaseUrl() {
return document.getElementsByTagName('base')[0].href;
}
platformBrowserDynamic(providers).bootstrapModule(AppModule)
.catch();
console.log("End of main.ts");
Removing the 'platformBrowserDynamic' function resolves the aforementioned error, but the page remains empty.
Below is an excerpt from my app.module.ts file (note: some imports have been omitted for brevity):
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
// import various modules and components...
@NgModule({
// module configuration...
})
export class AppModule { }