未捕获的 SyntaxError:严格模式代码可能不包含 with 语句
我最近更新到 Angular v9,但出现以下错误:
I have recently updated to Angular v9 and I am getting the following error:
未捕获的语法错误:严格模式代码可能不包含 with声明
Uncaught SyntaxError: Strict mode code may not include a with statement
这发生在以下文件中:
./node_modules/@angular/animations/__ivy_ngcc__/fesm2015/animations.js
根据文件中的注释,这是一个 Angular v9 文件:
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/ * 许可证:MIT */
/** * @license Angular v9.0.0 * (c) 2010-2020 Google LLC. https://angular.io/ * License: MIT */
这里发生了,使用 with
语句:
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);
},
此行上方有一条注释:
/* Domino 使用 sloppy-mode 特性(特别是 with
)* 小事.这个文件封装了所有的草率;每个 * 其他模块都应该是严格的.// jshint 严格:false // jshint邪恶:真实 // jshint -W085 */
/* 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 */
我正在寻找类似问题的解决方案.升级到 Angular 9 破坏了我的应用程序.经过多次反复试验这对我有帮助.
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.
只需从 main.ts
中注释掉或删除以下行(由升级过程添加):
Just comment out or remove the following line from main.ts
(added by the upgrade process):
export { renderModule, renderModuleFactory } from '@angular/platform-server';