【问题标题】:Angular 13.x - How to fix import * as i0 from '@angular/core' issue?Angular 13.x - 如何修复 import * as i0 from '@angular/core' 问题?
【发布时间】:2021-12-11 03:43:47
【问题描述】:

我确实将我的应用从 Angular 12.x 升级到了 13.x 版

构建和服务等工作正常。但是当我尝试执行 e2e-test 时,我遇到了以下错误:

E/launcher - Error: /Users/userName/PROJECT_NAME/node_modules/read-mail/
fesm2015/read-mail.mjs:1

import * as i0 from '@angular/core';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (/Users/userName/PROJECT_NAME/node_modules/coffeescript/
lib/coffee-script/register.js:45:36)

我一直在搜索并尝试了几个修复.. 他们都没有帮助。我也没有在 Angular 社区的 GitHub Repo 上具体提及此类错误。

任何提示或想法可能导致此类错误? Angular 13.x 版有问题吗?

【问题讨论】:

  • 我遇到了类似的问题,包括“esm support”+您的 e2e 框架和转译器(Coffeescript?)在您的搜索字词中可能会带回相关结果。

标签: angular typescript angular-e2e


【解决方案1】:

将此标志添加到您的tsconfig.json 文件中,位于compilerOptions

...
"allowSyntheticDefaultImports": true,
...

这为我解决了这个问题

【讨论】:

  • 我一直在尝试这个选项。它没有解决问题。谢谢!
猜你喜欢
  • 2021-09-26
  • 2021-11-01
  • 1970-01-01
  • 2019-06-07
  • 1970-01-01
  • 2020-05-11
  • 2020-11-01
  • 2015-07-31
  • 1970-01-01
相关资源
最近更新 更多