Getting ENOENT: no such file or directory, lstat 'C:\Users\nitrathod\Desktop\Angular\node_modules' in Angular 11 project

Viewed 16615

When I am trying to run the angular app below error is displayed.

An unhandled exception occurred: ENOENT: no such file or directory, lstat 'C:\Users\nitrathod\Desktop\Angular\node_modules' See "C:\Users\NITRAT~1\AppData\Local\Temp\ng-kzNmoN\angular-errors.log" for further details.

Error message screenshot

Tried npm install to resolve this issue.

after npm install

Project structure for more clarity. Project sturcture

3 Answers

check your angular.json.

I had this problem

    "styles": [
      "src/styles.css",
      "../node_modules/font-awesome/css/font-awesome.css"
    ],

Should have been

    "styles": [
      "src/styles.css",
      "./node_modules/font-awesome/css/font-awesome.css"
    ],

This caused it to look for node_modules in the wrong place

Make sure to run npm install to install all the required dependencies.

EDIT: Looking at your screenshots, It seems that for some reason, your application is looking for the node_modules directory at the wrong place when you run ng serve:

It should be in C:\Users\nitrathod\Desktop\Angular\outlook\node_modules, yet your application is looking into C:\Users\nitrathod\Desktop\Angular\node_modules, which is a wrong place.

I had the same problem, I just run: ng uninstall @angular/materialn to remove angular material theme from my project and then deleted "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css" from angular.json file. It solved my issue.

Related