【问题标题】:Module not found: Error: Can't resolve '@angular/platform-browser/animations' from src directory未找到模块:错误:无法从 src 目录解析 \'@angular/platform-b​​rowser/animations\'
【发布时间】:2022-10-26 00:38:53
【问题描述】:

我真的不确定为什么编译器试图阅读动画来自 source(src) 文件夹的引用,而不是来自 App.Module 的 Ng Build 上的 Node_Modules 。

在 angular.json 中给出了正确的路径,我确定如果我遗漏了一些简单的东西,你的意见会有所帮助。

错误:

 Module not found: Error: Can't resolve '@angular/platform-browser/animations' in 'C:\MySolution\AngApp\Client\AppName\src'

这仅在我执行 ngBuild 时发生,VSCode 中的代码显示没有错误并且“@angular/platform-b​​rowser”似乎没有抛出错误,它可能正确地引用了节点模块目录。

【问题讨论】:

    标签: angular


    【解决方案1】:

    将此模块从 angular 导入到 app.module

    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    
    imports: [BrowserAnimationsModule]
    

    【讨论】:

    • 我已经有了上面的配置
    猜你喜欢
    • 2019-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-02
    • 2016-10-25
    • 2018-11-16
    • 2021-04-23
    相关资源
    最近更新 更多