ENOENT: no such file or directory, lstat '/Users/Desktop/node_modules'

Viewed 85995

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.

25 Answers

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"

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

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!

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.

I got into this issue after installing ngx-bootstrap

> ng add ngx-bootstrap

Following went in angular.json

"styles": [
 "./dist/ngx-bootstrap/datepicker/bs-datepicker.css",
 "./node_modules/bootstrap/dist/css/bootstrap.min.css",
 "src/styles.css"
]

Changed to following and error got fixed

"styles": [
  "node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
  "node_modules/bootstrap/dist/css/bootstrap.min.css",
  "src/styles.css"
]

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

if: npm install bootstrap then "./node_modules/bootstrap/dist/css/bootstrap.min.css"

if npm install --save bootstrap then "node_modules/bootstrap/dist/css/bootstrap.min.css"

I was facing similar error:

 An unhandled exception occurred: ENOENT: no such file or directory, lstat 
'C:\User_Name\Angular\node_modules\bootstrap'
See "C:\Users\User_Name\AppData\Local\Temp\ng-MhR1Ls\angular-errors.log" for further details.

This was caused due to adding this in styles array:

    "styles": [
          "src/styles.css",
          "../node_modules/bootstrap/dist/css/bootstrap.min.css"
        ]

Solved it by changing styles array with

    "styles": [
          "src/styles.css",
          "node_modules/bootstrap/dist/css/bootstrap.min.css"
        ]

This may have happened cause I made another angular project inside the parent folder or directory since "." denotes the home directory. This is just my understanding and the solution of the issue.

Please check whether you have added your current component.html file i.e. unique selector in your app.component.html file

Recently started my angular journey so cheers!!

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.

Just do:

npm install --force and then npm audit fix --force

I'm had the same problem with my angular project after installing Boostrap.

My approach was:

angular.json file should have this under styles. "./node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.css"

Then import in the main style.css file.

@import url('../node_modules/bootstrap/dist/css/bootstrap.min.css');

Make sure the path for node_modules is correct,

After making those changes I ran ng serve or npm start Angular app is running

check angular.json file. sometimes style css pointing to the node modules may be incorrect

 "styles": [
 "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
              "src/styles.scss",
              "node_modules/primeicons/primeicons.css",
              "node_modules/primeng/resources/themes/lara-light-blue/theme.css",
              "node_modules/primeng/resources/primeng.min.css"
        ],
  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/

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

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

Usually, it happens when

package-lock.json

was created by another version of the node js (I'm using the latest LTS version).

Just remove it and try again, this is OK.

I just had the same issue, I removed the followings from angular.json which I had just added and the issue is resolved.

          "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
          "src/styles/styles.scss",
          "src/styles/colors.scss"

Step 1) npm install --save bootstrap

Step 2) and then add in angular.json at "styles": "./node_modules/bootstrap/dist/css/bootstrap.min.css",

Step 3) ng serve

Problem solved

image showing the solution

I removed the file from angular.json and added it to style.css.

@import '../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css'

Angular.js & Wrong Directions.

First of all, open a file called angular.js in the root folder.

And check if you add some wrong Directory. like the style or something like that. as example.

Suppose you add the bootstrap dependency and you want to add it to your project you will go to the angular.js and add it in the style configuration. so you will add it as the below:

 "styles": [
              "../node_modules/bootstrap/dist/css/bootstrap.min.css",
              "src/styles.css"
            ],

Check if you add double dot .. not one dot in the path like the below:

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

Correct format is as the below :

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

In the angular.json file just do this change :

"styles" : [ "node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.css" ]

I think the issue could be one of many flavors. Mine was specifically, in the relative path of bootstrap.min.css that was specified in angular.json

The error message that I had in the logs was:
"[error] Error: ENOENT: no such file or directory, lstat 'C:\Users\arsth\node_modules'"

I was following a tutorial video and provided the path as ../node_modules/bootstrap/dist/css/bootstrap.min.css.

But in my project, the angular.json file is actually at the same level as the node_modules folder. So correcting the above entry to ./node_modules/bootstrap/dist/css/bootstrap.min.css solved the issue.

remove all node_module or remove node_moules folder and type npm install

Bumped against the same issue with the quickstart tutorial. After restarting the tutorial and using yarn instead of npm, everything seems working fine.

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

Related