29

I am new to Angular 6 ,In my project I got the below error

 ERROR in multi ./node_modules/bootstrap/dist/css/bootstrap.min.css ./styles.css
Module not found: Error: Can't resolve 'C:\Users\User\e-CommerceWebsite\styles.css' in 'C:\Users\User\e-CommerceWebsite'

and the browser shows

cannot Get

angular.json

 "styles": [
          "./node_modules/bootstrap/dist/css/bootstrap.min.css",
          "styles.css"
        ],
        "scripts": [
          "./node_modules/jquery/dist/jquery.min.js",
          "./node_modules/popper.js/dist/popper.min.js",
          "./node_modules/bootstrap/dist/js/bootstrap.min.js"
        ]

styles.css

@import '~bootstrap/dist/css/bootstrap.min.css';
...
...
...

Referred this : bootstrap not connect to the angular 6?

Can anyone help me to fix this error .

2

33 Answers 33

18

In angular 6 angular.json file, use the bootstrap or font-awesome css file like this will fix your issue.

   "styles": [
          {
            "input": "./node_modules/bootstrap/dist/css/bootstrap.min.css"
          },
          {
            "input": "./node_modules/font-awesome/css/font-awesome.min.css"
          },
          "src/styles.css"
        ],
1
  • 1
    still not able to fix it in ng6,
    – Developer
    Commented Feb 1, 2019 at 6:11
8

It basically takes the wrong path. We need to put the path as ../node_modules/bootstrap/dist/css/bootstrap.min.css instead of node_modules/bootstrap/dist/css/bootstrap.min.css.

4
  • Hi Pranendu, is that actually an answer?
    – hakamairi
    Commented Aug 6, 2018 at 15:46
  • Yes..I faced this same issue myself and fixed ...!! Commented Aug 8, 2018 at 4:50
  • Hi Hakamairi , ++ I am very new user to STACKOVERFLOW ...so I just posted the solution the way I got it , anything wrong in this approach ? please clear . Commented Aug 8, 2018 at 5:21
  • Even in my case path was incorrect..After correcting style.css path my issue get resolved Commented Nov 27, 2018 at 12:49
6

this work for me

  "styles": [
         {
            "input": "./node_modules/bootstrap/dist/css/bootstrap.min.css"
          },
          "src/styles.css"
        ],
0
4

The only solution that worked for me:

1/   delete "node-modules"
2/   "npm install [email protected] --save"
3/   "npm install"
4/   "npm rebuild node-sass"
4

I had this problem too. Do this:
in angular.json file, use on of these declarations (pay attention to "." and "/"):

"styles": [
          {
            "input": "./node_modules/bootstrap/dist/css/bootstrap.min.css"
          },
          {
            "input": "./node_modules/font-awesome/css/font-awesome.min.css"
          },
          "src/styles.css"
        ],

or

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

Don't forget to rebuild project to see changes

3

I faced the same error. According to your file path answer is changed. Just look at your path and correct it as following ways.

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

            ],

or

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

        ],
3

Literally the wrong path is the reason. Include src/ in front of style.css.

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

I've encountered this one many times when creating new projects.

  • Make sure the path of the bootstrap.min.css coincide with the path in the error message and angular.json
  • Stop the application when making changes to angular.json file
  • Run again

it's either

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

or

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

depending on the path from the error message

1

Add bootstrap to the angular json configuration file instead of the styles.css (it doesn't work because it's css, not scss).

"styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "styles.scss"
      ],
1
  • I got this after applying the above two lines ERROR in multi ../node_modules/bootstrap/dist/css/bootstrap.min.css ./styles.scss Module not found: Error: Can't resolve 'C:\Users\User\e-CommerceWebsite\styles.scss' in 'C:\Users\User\e-CommerceWebsite' ERROR in multi ../node_modules/bootstrap/dist/css/bootstrap.min.css ./styles.scss Module not found: Error: Can't resolve 'C:\Users\User\node_modules\bootstrap\dist\css\bootstrap.min.css' in 'C:\Users\User\e-CommerceWebsite' @Carsten
    – Zhu
    Commented Jun 26, 2018 at 4:56
1

Worked for me !

"styles": [{
    "input": "./node_modules/bootstrap/dist/css/bootstrap.min.css"
  },
  {
    "input": "./node_modules/ti-icons/css/themify-icons.css"
  },
  "src/assets/icon/icofont/css/icofont.min.css",
  "src/styles.css"
]

1
  • 3
    For a useful answer this reaction needs to be extended. Explain why this is an answer to the question. Commented Oct 7, 2018 at 7:00
1

I struggled with this error. Just look at your path and correct as following.

"styles": [
          "node_modules/@nebular/theme/styles/prebuilt/default.css"
        ],
1

I had the same issue. This one works for me.

 "styles": [
          "node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
          "node_modules/bootstrap/dist/css/bootstrap.css",
          "src/sass/styles.scss"
        ],

and also this one works.

"styles": [
          "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
          "./node_modules/bootstrap/dist/css/bootstrap.css",
          "src/sass/styles.scss"
        ]
1

I had the same issue, this worked out for me.

angular.json:

"styles": [             
            "src/styles.css"              
        ],

styles.css:

@import "~../node_modules/bootstrap/dist/css/bootstrap.min.css";
1

I have the same issue then I apply below path like this without dot (.) and slash/

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

I had a similar problem using ngx-toastr with Angular 8. I had to place the .css styles references in the following order within the angular.json file:

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

And the @imports within the styles.css file in the following order:

 @import '~bootstrap/dist/css/bootstrap.min.css';
 @import '~ngx-toastr/toastr.css';

It solved the problem.

1

I was having almost same issue, I tried uninstalling and reinstalling Bootstrap package also but it did't prove fruitful.

ERROR in multi ../node_modules/bootstrap/dist/css/bootstrap.min.css ./src/styles.css Module not found: Error: Can't resolve 'D:\angular\node_modules\bootstrap\dist\css\bootstrap.min.css' in 'D:\angular\jsonFile'

My path in angualr.json was

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

removing front dots worked for me.

"node_modules/bootstrap/dist/css/bootstrap.min.css"
1
The problem can be solved in two ways:

1. Go to angular.json and under styles add the following lines

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

            ],

Or

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

              ],

Please try them the second one worked for me

2. Go to the file named "styles.css" and add the following line of code.

 @import '~bootstrap/dist/css/bootstrap.min.css';
1

I had the same issue with a brand new angular 7 project. Just Installed it, npm start and got the error: ERROR in multi ./src/styles.sass So I opened angular.json and:

      "styles": [
         "src/styles.sass"   <--  I had styles.scss file, not this styles.sass
       ],

I just renamed styles.sass to styles.scss because that file was present in the project folder and npm start again. This resolved my issue.

1

I update by using npm update command after i got the same error. I changed my angular.js file in styles removed F:\xxxx\node_modules\ngx-select-dropdown\dist\assets\style.css', css file is not present there. I saved and stopped my angular cli, again run cli ng serve. It started working fine.

https://github.com/manishjanky/ngx-select-dropdown/issues/112 latest version the style.css is no longer relevant, that's why i removed the last css file of ngx-select-dropdown. That's all.

1

This type issue generates due to wrong path of files.

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

1

I believe there is only one solution for this. Issue is path. Buyt typing down ./ or input is not going to help. If you getting ""ERROR in multi ./node_modules/bootstrap/dist/css/bootstrap.min.css"" error that means you didn't install it in the correct place. If you are studying from a book or so then the easy solution is to navigate to Command prompt and navigate to your project folder and install bootstrap there. Or give the full path to bootstrap on angular.jason file.

0

Why you angular.json

 "styles": ["styles.scss"],
 "scripts": []

But your global style is styles.css

enter image description here


Please make sure you have style.scss file. Because the error throw is you don't have the style.scss file.

1
  • please take a look at my updated post ,still I got the error after changing the scss to css @DinhDuong
    – Zhu
    Commented Jun 26, 2018 at 6:26
0

You can either import the bootstrap.min.css from node modules into the styles.css file like

@import ~/bootstrap/dist/css/bootstrap.min.css;

Or add this bootstrap file in the angular(-cli).json (this file will be cli.json until Angular 5 and in 6 its just angular.json) file under styles [].

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

We just need to figure out the right path for the parser to be able to find the path where bootstrap is installed.

0

I replaced these styles from angular.json

"styles": ["src/styles.css"]

to

"styles": ["styles.css"]

It worked for me!

0

check whether the respective files which we linked under 'styles' and 'scripts' are available under node modules folder. Recently in my project, I got this issue while updating packages. I noticed that some files which we referred angular cli JSON got missed. This error has been resolved after adding the necessary files. Hope it helps.

0

I think it is because of the problem with bootstrap, try this: Step 1. Remove "../node_modules/bootstrap/dist/css/bootstrap.min.css" Step 2. Go to styles.css Import bootstrap by adding this line @import "~bootstrap/dist/css/bootstrap.css"; These steps solved the errors I got during the building process.

0

Try below mentioned command:

npm rebuild node-sass

0

In angular 6 you have to delete this line from your angular.json "./node_modules/bootstrap/dist/css/bootstrap.min.css",

it well work fine.

0

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

0

They started from outside of project folder and you need to link to src and direct them to styles.css file. Copy this:

"src/styles.css"

~Khai Lim

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.