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

Angular与ASP.NET启动报错:无法打开网页及Vite相关错误求助

问题描述

我编写了一个简单的ASP.NET Web API,随后在cmd中执行ng new创建了Angular项目。将文件夹在VS Code中打开后,在终端执行ng serve --open。我已安装Angular、npm、node、VS Code及Visual Studio的最新版本并确认兼容性,多次重装Angular、node与npm,但仍出现以下报错:

Application bundle generation complete. [3.392 seconds]
Watch mode enabled. Watching for file changes...
  ➜  Local:   http://localhost:4200/
Vite Error, /@fs/C:/Users/1/Desktop/C#/ASP NET/AngularWebApi/PaymentApplication/.angular/cache/17.0.6/vite/deps/@angular_platform-browser.js?v=4241c9d8 optimized info should be defined
Vite Error, /@fs/C:/Users/1/Desktop/C#/ASP NET/AngularWebApi/PaymentApplication/.angular/cache/17.0.6/vite/deps/@angular_router.js?v=4241c9d8 optimized info should be defined
Vite Error, /@fs/C:/Users/1/Desktop/C#/ASP NET/AngularWebApi/PaymentApplication/.angular/cache/17.0.6/vite/deps/@angular_core.js?v=4241c9d8 optimized info should be defined
Vite Error, /@fs/C:/Users/1/Desktop/C#/ASP NET/AngularWebApi/PaymentApplication/.angular/cache/17.0.6/vite/deps/@angular_common.js?v=4241c9d8 optimized info should be defined
Vite Error, /@fs/C:/Users/1/Desktop/C#/ASP NET/AngularWebApi/PaymentApplication/.angular/cache/17.0.6/vite/deps/@angular_router.js?v=4241c9d8 optimized info should be defined
Vite Error, /@fs/C:/Users/1/Desktop/C#/ASP NET/AngularWebApi/PaymentApplication/.angular/cache/17.0.6/vite/deps/@angular_core.js?v=4241c9d8 optimized info should be defined
Failed to load url C:/Users/1/Desktop/C#/ASP NET/AngularWebApi/PaymentApplication/node_modules/vite/dist/client/env.mjs (resolved id: C:/Users/1/Desktop/C#/ASP NET/AngularWebApi/PaymentApplication/node_modules/vite/dist/client/env.mjs) in C:/Users/1/Desktop/C. Does the file exist?
解决方案
  • 清理Angular缓存:删除项目根目录下的.angular/cache文件夹,重新执行ng serve。缓存文件损坏是触发这类Vite优化信息错误的常见原因。
  • 更换项目路径:当前项目路径包含#符号和空格,Vite对带特殊字符的路径支持存在问题。将项目迁移到无特殊字符、无空格的路径下,比如C:/Users/1/Desktop/AngularWebApi/PaymentApplication。
  • 重装依赖:删除node_modules文件夹和package-lock.json文件,执行npm install重新安装所有依赖,再尝试启动项目。
  • 更新Angular相关包:运行npm update @angular/cli @angular-devkit/build-angular,确保Angular CLI和内置Vite的版本兼容,避免版本不匹配导致的加载错误。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.04 15:07:42