5
votes

An unhandled exception occurred:

ENOENT: no such file or directory, lstat 
'/Users/Desktop/node_modules'
See "/private/var/folders/3p/l_k1wk8n76v3cfwnxk0blx000000gn/T/ng- 
DF5EZ7/angular-errors.log" for further details.

Whenever i am doing ng serve, this error occurs, Can anyone tell me what is the cause of error. stuck in this since long hours.

11
Are you running the command in the root of your project folder?Daniel B
yes, previously it was running, after some when again i did ng serve , this error is showing, i had to create new project but in that too after another ng serve this same error occuring, why this is happening.shristy sinha
if your project can be uploaded to github or somewhere else that would be the best, but the error may persint in the package.json file. Please try to rerunn npm install againRichárd Baldauf

11 Answers

13
votes

I had this problem, it was just:

  1. Works "styles": [ "node_modules/bootstrap/dist/css/bootstrap.min.css"

  2. Not works "styles": [ "../node_modules/bootstrap/dist/css/bootstrap.min.css"

2
votes

I had the same error when I tried installing an old version of bootstrap and referenced it in the angular.json file. Meanwhile, the package was never installed because it doesn't exist anymore. Check the new command for installing a particular package and after doing npm i <package-name> check in node_modules if it's there.

And also, I changed my bootstrap path from

../node_modules/bootstrap/dist/css/bootstrap.css

to

node_modules/bootstrap/dist/css/bootstrap.css
1
votes

Solving the problems on angular.json then deleting package-lock.json solved my problem.

My problem was related to a deleted package @angular/material. Angular.json styles were still referencing that package, I deleted those lines. Then I deleted the package-lock.json and execute it.

0
votes
  1. Download manually bootstrap from https://www.npmjs.com/package/bootstrap .
  2. Copy and past the folder you download to /Users/Desktop/node_modules .
  3. In CMD, enter to your project folder you created by typing: CD yourProjectName .
  4. In CMD: ng serve.
  5. In your browser: http://localhost:4200/
0
votes

In my case i removed the "../node_modules/bootstrap/dist/css/bootstrap.min.css" from angular.json

0
votes

In my case, my problem was a misspelling issue in the directory URL inside Angular.json. So I corrected the error and the apps run perfectly afterwards.

Not working: (misspelled on "node_modules")

"styles": ["./node_moodules/font-awesome/css/font-awesome.css"]

Working:

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

try checking your url path in Angular.json, this probably the case, hopefully this helps!

0
votes

I had the same problem. But I found a Solution which works for me.

Try:

npm install --save bootstrap

and then add in angular.json at "styles":

"node_modules/bootstrap/dist/css/bootstrap.min.css"

run the Project (Watch if youre in the right folder you can check it with typing in terminal ls and and then you should see node_modules, src etc.)

ng serve

0
votes

I had this problem on a non-Angular project; here's what worked for me:

  1. update node and npm
  2. delete package-lock.json
  3. run npm install --package-lock-only
0
votes

As @Manuel Villadiego said, you must define your bootstrap path like below:

"node_modules/bootstrap/dist/css/bootstrap.min.css"

Or

"./node_modules/bootstrap/dist/css/bootstrap.min.css"

This error will happen when you start bootstrap path with ../ ,

"../node_modules/bootstrap/dist/css/bootstrap.min.css"

because you go back one folder and node_modules folder doesn't exist there.

-1
votes

So to sum up what is the cause of the issue. Its that the node_modules is not being read well from the angular.json file

-2
votes

You need to check with the path of bootstrap in angular.json inside architect then styles