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.
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
I had this problem, it was just:
Works "styles": [ "node_modules/bootstrap/dist/css/bootstrap.min.css"
Not works "styles": [ "../node_modules/bootstrap/dist/css/bootstrap.min.css"
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
You need to check with the path of bootstrap in angular.json inside architect then styles
In my case i removed the "../node_modules/bootstrap/dist/css/bootstrap.min.css" from angular.json
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.
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!
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
I had this problem on a non-Angular project; here's what worked for me:
npm install --package-lock-only
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.
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.
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"
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
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"
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!!
I removed the file from angular.json
and added it to style.css
.
@import '../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css'
Just do:
npm install --force
and then npm audit fix --force