Mauricio Gracia Gutierrez
Mauricio Gracia Gutierrez

Reputation: 10862

Angular app has stoped running and has the folder "node_modules" misplaced into "src"

I have a angular application that was working fine now after many months of not touching the code when I try to run the ng serve it show me the following error

An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\commands\serve-impl.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\utilities\json-schema.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\models\command-runner.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
See "C:\Users\MGG\AppData\Local\Temp\ng-5bEONa\angular-errors.log" for further details. 

IMPORTANT

when I run ng version I am getting this error

D:\MAO\repos\ApParquear\src>ng version An unhandled exception occurred: ENOENT: no such file or directory, scandir 'D:\MAO\repos\ApParquear\node_modules'

And I have checked and the folder is not there, there is one node_modules folder inside the "src" folder that I am working, so it seems that something in my project structure is wrong how can I fix it ?

Things that I have tried

So I have tried running this command:

npm install --save-dev @angular-devkit/build-angular

After that installation I get many of this warnings after an apparent succesfull installation

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\webpack-dev-server\node_modules\fsevents\node_modules\wrappy):       
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'D:\MAO\repos\ApParquear\src\node_modules\webpack-dev-server\node_modules\fsevents\node_modules\wrappy' -> 'D:\MAO\repos\ApParquear\src\node_modules\webpack-dev-server\node_modules\fsevents\node_modules\.wrappy.DELETE'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\webpack-dev-server\node_modules\fsevents\node_modules\yallist):     
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename 'D:\MAO\repos\ApParquear\src\node_modules\webpack-dev-server\node_modules\fsevents\node_modules\yallist' -> 'D:\MAO\repos\ApParquear\src\node_modules\webpack-dev-server\node_modules\fsevents\node_modules\.yallist.DELETE'

+ @angular-devkit/[email protected]
added 1011 packages from 531 contributors and audited 11775 packages in 118.015s

31 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

So after that I try agin the "ng serve" but still get the same error

An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Require stack:
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\index.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\commands\serve-impl.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\export-ref.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\tools\index.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\utilities\json-schema.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\models\command-runner.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\lib\init.js
- C:\Users\MGG\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
See "C:\Users\MGG\AppData\Local\Temp\ng-TsMNQa\angular-errors.log" for further details.

I have searched many things, I even try to migrate from version 8 of node to 12 but it was worse.

So apparently my project structure has missing some important things, how can I fix them ?

Upvotes: 0

Views: 1352

Answers (2)

Pratibha Yadav
Pratibha Yadav

Reputation: 1

Install angular cli globally:

npm install -g @angular/cli

Upvotes: 0

Mile Mijatović
Mile Mijatović

Reputation: 3177

Run npm install in root folder of your project, that will install all missing dependency from package.json file (all your missing dependencies) .

You tried npm install --save-dev @angular-devkit/build-angular but that's not the same as npm install

Upvotes: 1

Related Questions