angular-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 (<anonymous>) 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 (<anonymous>) 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 4
  • Comments: 31 (1 by maintainers)

Commits related to this issue

Most upvoted comments

@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.

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!

I dont know , what the issue is your facing but in mine , i tried with refering stack overflow npm uninstall -g angular-cli npm cache clean or npm cache verify (if npm > 5) npm install -g @angular/cli@latest rm -rf node_modules npm uninstall --save-dev angular-cli npm install --save-dev @angular/cli@latest npm install and including my css by removing tilde sign (~nodemodules/…css to …/nodemodules/…css )

i had the same issue but solved when i’ve set @import ‘bootstrap/dist/css/bootstrap.css’; instead of @import ‘~bootstrap/dist/css/bootstrap.css’;

in the style.css , same solution as hassansw

I don’t seem to be able to successfully import any css file in node_modules. Neither by using a relative path nor by using the ~. Imports that are in my application itself can be imported.

@import '~angular-tree-component/dist/angular-tree-component.css'; doesn’t work

@import url('../../../../node_modules/font-awesome/css/font-awesome.min.css'); doesn’t work

@import url('./sidebar.css'); this works

I implemented it same as @tiandiduwuxiaoxiao in the global css – getting the same error. If I move the bootstrap.css file to the root of the node modules folder

"styles": [ "styles.css", "../node_modules/bootstrap.css" ], or anywhere else above the node_modules directory, no problem. Seems like a problem with traversing the directory tree.

(Working with Angular CLI 1.6.4 and Angular 5.2.1) I was @importing “…/node_modules/material-design-icons/iconfont/material-icons.css” in my main stylesheet. I removed the @import and instead referenced this stylesheet in .angular-cli.json and it solved my problem.