404(未找到)错误
优化 deps 目录中的路径 >/.angular/cache/18.1.4/vite/deps/browser-VFYTEBP2.js?v=ef5c984d" 不存在该文件。该依赖项可能与 dep 优化器不兼容尝试将其添加到
。optimizeDeps.exclude
我调试的时候,在Vite文档中找到了以下内容
https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude
export default defineConfig({
optimizeDeps: {
include: ['esm-dep > cjs-dep'],
},
})
我应该在 Angular 项目中的哪里添加它才能生效
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
"@angular/animations": "^18.1.4",
"@angular/cdk": "^18.1.4",
"@angular/common": "^18.1.4",
"@angular/compiler": "^18.1.4",
"@angular/core": "^18.1.4",
"@angular/forms": "^18.1.4",
"@angular/material": "^18.1.4",
"@angular/platform-browser": "^18.1.4",
"@angular/platform-browser-dynamic": "^18.1.4",
"@angular/router": "^18.1.4",
"optimization": {
"scripts": true,
"styles": {
"minify": true,
"inlineCritical": false
},
"fonts": true
}
我有一个类似的错误,但在 React 项目中,我通过运行以下命令解决了它:
rm -rf node_modules/.vite
这个命令会清除Vite的缓存,之后我重新启动开发服务器就可以正常工作了