You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行ng serve时出现Primordials is not defined错误(未安装Gulp)

解决Angular项目ng serve报primordials is not defined错误的方案

问题根源

你当前调用的是全局安装的旧版Angular CLI,而非项目本地的@angular/cli@18.2.6。全局CLI版本与Node.js v20.17.0不兼容,其依赖的老旧graceful-fs模块无法适配高版本Node,导致出现primordials is not defined错误。

解决步骤

  • 卸载全局旧版Angular CLI:
    npm uninstall -g angular-cli
    
  • 清理npm缓存:
    npm cache clean --force
    
  • 安装与项目匹配的全局Angular CLI版本:
    npm install -g @angular/cli@18.2.6
    
  • 重新安装项目本地依赖:
    1. 删除项目根目录下的node_modules文件夹和package-lock.json文件
    2. 执行安装命令:
      npm install
      
  • 重新启动项目:
    ng serve
    

备选方案(避免全局版本干扰)

如果全局CLI仍有冲突,可直接调用项目本地的CLI:

npx ng serve

内容的提问来源于stack exchange,提问作者Thomas Jarrett

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 22:17:43