Solvedangular cli ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_ modules/postcss-loader/lib?{"ident":"postcss","plugins":[null,null,null],"source Map":false}!./node_modules/bootstrap/dist/css/bootstrap.css

Versions

<!--
Angular CLI: 1.5.5
Node: 8.9.1
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.5.5
@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.8.5
@schematics/angular: 0.1.11
@schematics/schematics: 0.0.11
typescript: 2.4.2
webpack: 3.8.1

-->

Repro steps

styles.css --->
@import '~bootstrap/dist/css/bootstrap.css';

Observed behavior

ERROR in ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_ modules/postcss-loader/lib?{"ident":"postcss","plugins":[null,null,null],"source Map":false}!./node_modules/bootstrap/dist/css/bootstrap.css
Module build failed: BrowserslistError: Unknown browser major
at error (D:\angular\organicShop\node_modules\browserslist\index.js:37:11)
at Function.browserslist.checkName (D:\angular\organicShop\node_modules\brow serslist\index.js:320:18)
at Function.select (D:\angular\organicShop\node_modules\browserslist\index.j s:438:37)
at D:\angular\organicShop\node_modules\browserslist\index.js:207:41
at Array.forEach ()
at browserslist (D:\angular\organicShop\node_modules\browserslist\index.js:1 96:13)
at Browsers.parse (D:\angular\organicShop\node_modules\autoprefixer\lib\brow sers.js:44:14)
at new Browsers (D:\angular\organicShop\node_modules\autoprefixer\lib\browse rs.js:39:28)
at loadPrefixes (D:\angular\organicShop\node_modules\autoprefixer\lib\autopr efixer.js:56:18)
at plugin (D:\angular\organicShop\node_modules\autoprefixer\lib\autoprefixer .js:62:18)
at LazyResult.run (D:\angular\organicShop\node_modules\postcss-loader\node_m odules\postcss\lib\lazy-result.js:277:20)
at LazyResult.asyncTick (D:\angular\organicShop\node_modules\postcss-loader\ node_modules\postcss\lib\lazy-result.js:192:32)
at LazyResult.asyncTick (D:\angular\organicShop\node_modules\postcss-loader\ node_modules\postcss\lib\lazy-result.js:204:22)
at processing.Promise.then._this2.processed (D:\angular\organicShop\node_mod ules\postcss-loader\node_modules\postcss\lib\lazy-result.js:231:20)
at new Promise ()
at LazyResult.async (D:\angular\organicShop\node_modules\postcss-loader\node _modules\postcss\lib\lazy-result.js:228:27)
@ ./node_modules/css-loader?{"sourceMap":false,"importLoaders":1}!./node_module s/postcss-loader/lib?{"ident":"postcss","sourceMap":false}!./src/styles.css 3:10 -186
@ ./src/styles.css
@ multi ./src/styles.css

32 Answers

✔️Accepted Answer

@myspivey Yeah I had the same experience. I don't use bootstrap either.

Downgrading to "@angular/cli": "1.6.3" fixed it for me. i.e. something changed in 1.6.4.

Other Answers:

Actually the problem is not happening for "bootstrap": "4.0.0-beta.2", so I have to shift to "bootstrap": "4.0.0-beta.3" in order to continue the project.I have updated the "^bootstrap": "4.0.0-beta.3" in th package.json file and run "npm install" and "ng serve".The problem is not happening in that case.

Package.json

{
"name": "sample-project",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"bootstrap": "4.0.0-beta.2",
"core-js": "^2.4.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.5.5",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}

npm install

ng serve

Had the same issue. I temporary inserted all global .css to .angular-cli.json. Builds fine.

...
"styles": [
        "styles.css",
        "../node_modules/font-awesome/css/font-awesome.css",
        "../node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
        "../node_modules/material-design-icons/iconfont/material-icons.css"
      ],
...

change it to:
@import "@angular/material/prebuilt-themes/indigo-pink.css";

by removing ~ fixed my problem

The problem is not bootstrap related.
I get the same error when I am trying to use

@import "~@angular/material/prebuilt-themes/indigo-pink.css";

inside styles.css.
That means that I cannot use angular material components!

More Issues: