Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zone.js cannot be resolved

After upgrading to the latest Angular cli, when I run ng serve, I get the following error:

./node_modules/@angular-devkit/build-angular/src/webpack/es5-polyfills.js:106:0-37 - Error: Module not found: Error: Can't resolve 'zone.js/plugins/zone-legacy' in 'C:\Users\Reem\App\node_modules\@angular-devkit\build-angular\src\webpack'

I have tried every solution and suggestion in the posts that exist about zone.js related issues and errors, but nothing has resolved it...

Does anyone know how to fix this in the latest Angular version?

like image 446
Reem Al-Assaf Avatar asked Sep 25 '26 19:09

Reem Al-Assaf


2 Answers

I think you are missing latest package of angular in your project. You can try below. Delete current node module folder. Delete package lock file. Install npm install @angular/cli and then npm install. Try ng serve again.

like image 134
Sumit Avatar answered Sep 28 '26 22:09

Sumit


With Angular 20 you have to include the zone.js in the package.json. Until version 19, the library was already included in Anglular CLI (@angular/cli)

  "dependencies": {
    ...
    "@angular/compiler": "~20.1.7",
    ...
    "zone.js": "^0.15.1"  
like image 41
Andreas Panagiotidis Avatar answered Sep 28 '26 21:09

Andreas Panagiotidis