35

I have recently updated to Angular v9 and I am getting the following error:

Uncaught SyntaxError: Strict mode code may not include a with statement

This is occuring in the following file:

./node_modules/@angular/animations/__ivy_ngcc__/fesm2015/animations.js

This is an Angular v9 file as per the comments in the file:

/** * @license Angular v9.0.0 * (c) 2010-2020 Google LLC. https://angular.io/ * License: MIT */

This is occuring here, with the with statement:

module.exports = {
  Window_run: function _run(code, file) {
    if (file) code += '\n//@ sourceURL=' + file;
    with(this) eval(code);
  },

There is a comment above this line:

/* Domino uses sloppy-mode features (in particular, with) for a few * minor things. This file encapsulates all the sloppiness; every * other module should be strict. / / jshint strict: false / / jshint evil: true / / jshint -W085 */

12
  • 1
    What is the question? Feb 7, 2020 at 13:49
  • 1
    What operation/IDE/linter/etc. is throwing the error? You say there's an error, you don't say where it's from. Feb 7, 2020 at 13:57
  • 1
    Yes, jshint is probably only obeyed by specific linters, not the browser.
    – deceze
    Feb 7, 2020 at 13:59
  • 2
    github.com/angular/angular/issues/34970
    – deceze
    Feb 7, 2020 at 14:02
  • 1
    Browsers aren't jshint, browsers are browsers. Feb 7, 2020 at 14:06

2 Answers 2

103

I was searching for the solution to a similar problem. Upgrade to Angular 9 broke my app. After a lot of trial and error this helped me.

Just comment out or remove the following line from main.ts (added by the upgrade process):

export { renderModule, renderModuleFactory } from '@angular/platform-server';
3
0

I removed this line export { renderModule, renderModuleFactory } from '@angular/platform-server'; as suggested here and here but the issue occures only when I add ServerModule to imports array

@NgModule({
  imports: [/*AppModule,*/ ServerModule],
  //  bootstrap: [AppComponent],
})
export class AppServerModule {}
// export { renderModule, renderModuleFactory } from '@angular/platform-server';

when removing ServerModule the build executed successfully

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.