Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular vite optimisation

404 (Not Found) error

The file does not exist at path>/.angular/cache/18.1.4/vite/deps/browser-VFYTEBP2.js?v=ef5c984d" which is in the optimize deps directory. The dependency might be incompatible with the dep optimizer. Try adding it to optimizeDeps.exclude.

enter image description here

When I debug, I find the below in Vite Documentation

https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude

   export default defineConfig({
    optimizeDeps: {
      include: ['esm-dep > cjs-dep'],
    },
   })

where should I add this in angular project to take effect

package.json

"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",

angular.json

       "optimization": {
            "scripts": true,
            "styles": {
              "minify": true,
              "inlineCritical": false
            },
            "fonts": true
          }
like image 838
shiva krishna Avatar asked Aug 07 '26 04:08

shiva krishna


1 Answers

The solution to many Angular build problems:

Delete your node_modules folder, and your yarn.lock file and run yarn install. You should be good to go.

Using npm? Delete your node_modules folder, and your package-lock.json and run npm install.

Commit and push changes.

like image 166
Johan Faerch Avatar answered Aug 09 '26 11:08

Johan Faerch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!