angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Bootstrap styles not loading

Open faizy6641 opened this issue 8 years ago • 15 comments

Hi,

I followed the steps for Global Library Installation https://github.com/angular/angular-cli#global-library-installation

First I installed Bootstrap from npm by executing below command

npm install jquery --save npm install popper.js --save npm install bootstrap@next --save

Then i added the needed script files to apps[0].scripts: "scripts": [ "../node_modules/jquery/dist/jquery.slim.js", "../node_modules/popper.js/dist/umd/popper.js", "../node_modules/bootstrap/dist/js/bootstrap.js" ], then Restarted ng serve and getting below error: ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_modules/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./node_modules/bootstrap/dist/css/bootstrap.css Module build failed: BrowserslistError: Unknown browser major at error (C:\Users\faiyazs\Downloads\practice\node_modules\browserslist\index.js:37:11) at Function.browserslist.checkName (C:\Users\faiyazs\Downloads\practice\node_modules\browserslist\index.js:320:18) at Function.select (C:\Users\faiyazs\Downloads\practice\node_modules\browserslist\index.js:438:37) at C:\Users\faiyazs\Downloads\practice\node_modules\browserslist\index.js:207:41 at Array.forEach () at browserslist (C:\Users\faiyazs\Downloads\practice\node_modules\browserslist\index.js:196:13) at Browsers.parse (C:\Users\faiyazs\Downloads\practice\node_modules\autoprefixer\lib\browsers.js:44:14) at new Browsers (C:\Users\faiyazs\Downloads\practice\node_modules\autoprefixer\lib\browsers.js:39:28) at loadPrefixes (C:\Users\faiyazs\Downloads\practice\node_modules\autoprefixer\lib\autoprefixer.js:56:18) at plugin (C:\Users\faiyazs\Downloads\practice\node_modules\autoprefixer\lib\autoprefixer.js:62:18) at LazyResult.run (C:\Users\faiyazs\Downloads\practice\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:270:20) at LazyResult.asyncTick (C:\Users\faiyazs\Downloads\practice\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:185:32) at LazyResult.asyncTick (C:\Users\faiyazs\Downloads\practice\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:197:22) at processing.Promise.then._this2.processed (C:\Users\faiyazs\Downloads\practice\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:224:20) at new Promise () at LazyResult.async (C:\Users\faiyazs\Downloads\practice\node_modules\postcss-loader\node_modules\postcss\lib\lazy-result.js:221:27) @ ./node_modules/bootstrap/dist/css/bootstrap.css 4:14-127 @ multi ./node_modules/bootstrap/dist/css/bootstrap.css ./src/styles.css

Details: package.json: "@angular/router": "^5.0.0", "bootstrap": "^4.0.0", "core-js": "^2.4.1", "jquery": "^3.3.1", "popper.js": "^1.12.9

OS- Windows 7 Enterprise Angular CLI: 1.6.2 Node: 8.9.4 OS: win32 x64 Angular: 5.1.2 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

@angular/cli: 1.6.2 @angular-devkit/build-optimizer: 0.0.36 @angular-devkit/core: 0.0.22 @angular-devkit/schematics: 0.0.42 @ngtools/json-schema: 1.1.0 @ngtools/webpack: 1.9.2 @schematics/angular: 0.1.11 @schematics/schematics: 0.0.11 typescript: 2.4.2 webpack: 3.10.0

someone pls help me i am stuck at this point from past 2 weeks

faizy6641 avatar Feb 19 '18 23:02 faizy6641

I think it is because of the problem with bootstrap, try this: Step 1. Inside .angular-cli.json file

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

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.

athulreji avatar Feb 20 '18 11:02 athulreji

This is a duplicate of #9020 and fixed in v1.7

clydin avatar Feb 20 '18 20:02 clydin

The above solution worked for me

sasidharv avatar Aug 06 '18 09:08 sasidharv

I've tried everything as above, still i am getting error. what can i do now?

manojjha avatar Aug 08 '18 09:08 manojjha

I think it is because of the problem with bootstrap, try this: Step 1. Inside .angular-cli.json file

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

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.

This worked for me but, not in .angular-cli.json in angular.json :100: :+1:

rahulteja5555 avatar Sep 29 '18 15:09 rahulteja5555

Hola, la solución a este error es la siguiente:
"styles": [ "src/styles.css", "node_modules/bootstrap/dist/css/bootstrap.min.css" ],

Esto funcionó para mí

JanCarlosRamirezM avatar Oct 13 '18 13:10 JanCarlosRamirezM

He intentado todo lo anterior, todavía estoy recibiendo error. ¿Qué puedo hacer ahora?

Hola, la solución a este error es la siguiente: "styles": ["src / styles.css", "node_modules / bootstrap / dist / css / bootstrap.min.css" ],

Esto funcionó para mí

JanCarlosRamirezM avatar Oct 13 '18 13:10 JanCarlosRamirezM

I find it is because of the problem with bootstrap, try this: Step 1. Inside .angular-cli.json file

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

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

Step 2. Go to styles.css

Import bootstrap by adding this line @import https://github.com/import "~bootstrap/dist/css/bootstrap.css";

These steps solved the errors I got during the building process. Thanks and Regards Abhash Kumar Ranjan 8800945318 8317510954

On Sat, Oct 13, 2018 at 6:48 PM Ing. Jan Carlos Ramirez M. < [email protected]> wrote:

He intentado todo lo anterior, todavía estoy recibiendo error. ¿Qué puedo hacer ahora?

Hola, la solución a este error es la siguiente: "styles": ["src / styles.css", "node_modules / bootstrap / dist / css / bootstrap.min.css" ],

Esto funcionó para mí

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/9690#issuecomment-429541187, or mute the thread https://github.com/notifications/unsubscribe-auth/AfU60yz4NM2pEr8uWH3XkTe-VZ-ACMz7ks5ukegrgaJpZM4SLOa7 .

abhash01 avatar Oct 15 '18 06:10 abhash01

merci beaucoup g puis utiliser le fichier angular.json pour y mettre "styles": ["styles.css"] et le fichier style.scss pour y mettre @import "~bootstrap/dist/css/bootstrap.css";

habibatou avatar Dec 27 '18 16:12 habibatou

Problem solved using @import "~bootstrap/dist/css/bootstrap.css"; in style.css

but what the real issue with below code "styles": [ "styles.css", "../node_modules/bootstrap/dist/css/bootstrap.min.css" ]

muhammadshahidraficp avatar Jan 12 '19 15:01 muhammadshahidraficp

Problem solved using

@import "~bootstrap/dist/css/bootstrap.css"; in style.css

but what the real issue with below code in angular.json

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

screenshot from 2019-01-12 21-03-37

muhammadshahidraficp avatar Jan 12 '19 15:01 muhammadshahidraficp

Path should not have "../". It should be simply node_modules/bootstrap/dist/css/bootstrap.min.css. Check src/style.css path, it means relative path is from your project home folder.

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

aman-jft avatar Jan 27 '19 15:01 aman-jft

@aman-jft i doing

Path should not have "../". It should be simply node_modules/bootstrap/dist/css/bootstrap.min.css. Check src/style.css path, it means relative path is from your project home folder.

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

I have to restart the server and it works how silly I am. thanks for answer

dreadfear avatar Feb 24 '19 14:02 dreadfear

Path should not have "../". It should be simply node_modules/bootstrap/dist/css/bootstrap.min.css. Check src/style.css path, it means relative path is from your project home folder.

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

Thank you for your answer sir

leolelover93 avatar Mar 05 '19 15:03 leolelover93

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.