博客
关于我
ng build --aot --prod生成文件报错
阅读量:801 次
发布时间:2023-02-15

本文共 703 字,大约阅读时间需要 2 分钟。

Cannot read property 'create' of undefined 在 --prod 或 --aot 构建时的解决方案

在使用 Angular CLI 进行生产构建(--prod)或 AOT 编译时,可能会遇到以下错误:

Cannot read property 'create' of undefined

解决方法

zone.js 的版本号更新至 0.8.5,然后清除旧的依赖并重新安装。以下是详细的解决步骤:

  • 更新 Angular CLI

    首先,确保你的 Angular CLI 已经安装最新版本:

    npm uninstall -g angular-clinpm cache cleannpm install -g @angular/cli@latest
  • 清除旧的依赖文件

    删除 dist 目录下的 ng_modules 文件:

    rm -rf dist/ng_modules
  • 重新安装依赖

    安装最新版本的 Angular CLI 并更新相关依赖:

    npm uninstall --save-dev angular-clinpm install --save-dev @angular/cli@latestnpm install
  • 重新编译项目

    重新构建项目以确保问题已解决:

    ng build
  • 注意事项

    在进行上述操作之前,请确保你已备份项目数据,以防万一。如有问题,请参考 Angular CLI 的官方文档或相关问题报告:

    引用来源:https://github.com/angular/angular-cli/issues/6036

    转载声明

    本文最初发布于 Cnblogs

    你可能感兴趣的文章
    No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
    查看>>
    No module named cv2
    查看>>
    No module named tensorboard.main在安装tensorboardX的时候遇到的问题
    查看>>
    No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
    查看>>
    No new migrations found. Your system is up-to-date.
    查看>>
    No qualifying bean of type XXX found for dependency XXX.
    查看>>
    No resource identifier found for attribute 'srcCompat' in package的解决办法
    查看>>
    No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
    查看>>
    NO.23 ZenTaoPHP目录结构
    查看>>
    NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
    查看>>
    NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
    查看>>
    Node JS: < 一> 初识Node JS
    查看>>
    Node-RED中使用JSON数据建立web网站
    查看>>
    Node-RED中使用json节点解析JSON数据
    查看>>
    Node-RED中使用node-red-browser-utils节点实现选择Windows操作系统中的文件并实现图片预览
    查看>>
    Node-RED中使用Notification元件显示警告讯息框(温度过高提示)
    查看>>
    Node-RED中实现HTML表单提交和获取提交的内容
    查看>>
    Node.js 函数是什么样的?
    查看>>
    Node.js 实现类似于.php,.jsp的服务器页面技术,自动路由
    查看>>
    node.js 怎么新建一个站点端口
    查看>>