【问题标题】:Angular 14: Can't resolve ModuleAngular 14:无法解析模块
【发布时间】:2023-02-02 16:32:38
【问题描述】:

成功更新到 Angular 14 后,我们的 e2e cypress (v9) 测试无法编译。失败是由导入在 Angular 更新之前工作的内容引起的。

似乎 webpack 在错误的目录中查找,因为“node_modules”位于项目根目录下 (D:\git\template\projects\node_modules),请参见下文。为什么会出现问题,如何解决?

[1] Error: Webpack Compilation Error
[1] ./projects/e2e/integration/demo.spec.ts
[1] Module not found: Error: Can't resolve '@shift/simulator-plugins/plugins/simulatorplugin/simulatorplugin' in 'D:\git\template\projects\e2e\integration'
[1] resolve '@shift/simulator-plugins/plugins/simulatorplugin/simulatorplugin' in 'D:\git\template\projects\e2e\integration'
[1]   Parsed request is a module
[1]   using description file: D:\git\template\package.json (relative path: ./projects/e2e/integration)
[1]     Field 'browser' doesn't contain a valid alias configuration
[1]     Looked for and couldn't find the file at the following paths:
[1] [D:\git\template\projects\e2e\integration\node_modules]
[1] [D:\git\template\projects\e2e\node_modules]
[1] [D:\git\template\projects\node_modules]
[1] [D:\node_modules]

【问题讨论】:

    标签: angular typescript webpack cypress e2e-testing


    【解决方案1】:

    很可能是 Angular 14 的更新导致导入发生重大变化,导致 webpack 配置出现问题。这可能是由于一些原因,例如,

    • Angular 14 或不再支持您正在导入的库或模块
    • 模块的依赖项或配置已更改,破坏了与以前版本的 Angular 的兼容性。

    要解决此问题,请尝试将库更新为兼容版本,或者如果这不可能,请尝试使用不同的库。此外,您可以尝试更新您的 webpack 配置以正确定位“node_modules”目录,或更新导入路径以正确反映新位置。

    【讨论】:

      猜你喜欢
      • 2022-06-23
      • 2018-04-23
      • 2021-11-24
      • 2017-12-11
      • 1970-01-01
      • 2017-07-06
      • 2017-03-04
      • 2020-04-18
      • 1970-01-01
      相关资源
      最近更新 更多