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

BrowserslistError: Unknown browser major at error

Open marshallcool opened this issue 8 years ago • 93 comments

I just deleted the node_modules folder and put the packages back

macOs Node 8 node: 8 "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/compiler-cli": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/cli": "^1.5.0", "@angular/compiler-cli": "^5.0.0",

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.min.css Module build failed: BrowserslistError: Unknown browser major at error (/Users/aleksandrgusev/Documents/express_client/node_modules/browserslist/index.js:37:11) at Function.browserslist.checkName (/Users/aleksandrgusev/Documents/express_client/node_modules/browserslist/index.js:320:18) at Function.select (/Users/aleksandrgusev/Documents/express_client/node_modules/browserslist/index.js:438:37) at /Users/aleksandrgusev/Documents/express_client/node_modules/browserslist/index.js:207:41 at Array.forEach (native) at browserslist (/Users/aleksandrgusev/Documents/express_client/node_modules/browserslist/index.js:196:13) at Browsers.parse (/Users/aleksandrgusev/Documents/express_client/node_modules/autoprefixer/lib/browsers.js:44:14) at new Browsers (/Users/aleksandrgusev/Documents/express_client/node_modules/autoprefixer/lib/browsers.js:39:28) at loadPrefixes (/Users/aleksandrgusev/Documents/express_client/node_modules/autoprefixer/lib/autoprefixer.js:56:18) at plugin (/Users/aleksandrgusev/Documents/express_client/node_modules/autoprefixer/lib/autoprefixer.js:62:18) at LazyResult.run (/Users/aleksandrgusev/Documents/express_client/node_modules/postcss-loader/node_modules/postcss/lib/lazy-result.js:270:20) at LazyResult.asyncTick (/Users/aleksandrgusev/Documents/express_client/node_modules/postcss-loader/node_modules/postcss/lib/lazy-result.js:185:32) at LazyResult.asyncTick (/Users/aleksandrgusev/Documents/express_client/node_modules/postcss-loader/node_modules/postcss/lib/lazy-result.js:197:22) at LazyResult.asyncTick (/Users/aleksandrgusev/Documents/express_client/node_modules/postcss-loader/node_modules/postcss/lib/lazy-result.js:197:22) at processing.Promise.then._this2.processed (/Users/aleksandrgusev/Documents/express_client/node_modules/postcss-loader/node_modules/postcss/lib/lazy-result.js:224:20) at LazyResult.async (/Users/aleksandrgusev/Documents/express_client/node_modules/postcss-loader/node_modules/postcss/lib/lazy-result.js:221:27) @ ./node_modules/bootstrap/dist/css/bootstrap.min.css 4:14-131 @ multi ./src/styles.scss ./src/select.css ./node_modules/bootstrap/dist/css/bootstrap.min.css ./node_modules/font-awesome/css/font-awesome.min.css ./node_modules/primeng/resources/primeng.min.css ./node_modules/primeng/resources/themes/omega/theme.css ./node_modules/material-design-icons/iconfont/material-icons.css

marshallcool avatar Dec 28 '17 21:12 marshallcool

@alanreji i tried ur solution and it worked perfectly ... thnx

tmrfouad avatar Jan 30 '18 10:01 tmrfouad

  1. change the style.css to scss (and all the css to scss also).
  2. @import "../node_modules/bootstrap/scss/bootstrap.scss"; --> put this in the first line of style.scss
  3. remove the bootstrap.css or bootstrap.min.css at the angular-cli.json ng build --prod everything work accordingly. Thank guys.....

mokth avatar Jan 30 '18 10:01 mokth

thank you all for your help, the problem is solved!

marshallcool avatar Jan 30 '18 12:01 marshallcool

@mokth Are you saying you had to convert EVERY css file used in the project to scss or just the bootstrap files you're using/importing?

SteveIngels avatar Jan 30 '18 14:01 SteveIngels

Installing angular cli 1.6.6 solve the problem for me!

gabrielemilan avatar Jan 30 '18 22:01 gabrielemilan

1.6.6 does not solves the issue !

ernitishkumar avatar Jan 31 '18 12:01 ernitishkumar

@SteveIngels Just tried the solution @mokth provided.

You'll need to remove "../node_modules/bootstrap/dist/css/bootstrap.min.css" from .angular-cli.json. Then change "styles.css" to "styles.scss" in .angular-cli.json. Then change the actual file style.css to style.scss and add @import "../node_modules/bootstrap/scss/bootstrap.scss" to the top of the file.

joseph-schenck avatar Jan 31 '18 20:01 joseph-schenck

@joseph-schenck this solution worked and feels like the correct fix.

angular-cli 1.4.10 (have to run Angular 4 bc of LTS) bootstrap 4.0.0

jglisson avatar Feb 01 '18 14:02 jglisson

@jglisson this solution uses scss instead of the plain bootstrap compiled css, and skips the angular-cli way of styles inclusion by directly importing it to the main styles.css file.

It certainly does not seem to be an appropriate fix.

Nosfistis avatar Feb 01 '18 15:02 Nosfistis

@Miced thanks for your response.

It seemed appropriate because it doesn't alter the package.json browserlist for bootstrap. It uses the sass implementation rather than the css implementation, which seems fine to me.

What do you suggest?

jglisson avatar Feb 01 '18 15:02 jglisson

The next beta version, @angular/[email protected], successfully built in production mode without changing any of my files, as suggested by @filipesilva. I am using it already without any other issues.

Nosfistis avatar Feb 01 '18 18:02 Nosfistis

We are required to use Angular 4 because of LTS.

jglisson avatar Feb 01 '18 18:02 jglisson

1.7 will still support building Angular 4; as does 1.5 and 1.6. If you are encountering problems doing so, please open an issue describing the problem.

clydin avatar Feb 01 '18 19:02 clydin

Thanks @clydin

This may sound dumb then (and off topic, so I apologize). But how do you use ng new to create an angular 4 project with cli 1.5/6/7? I have been searching online quite a bit and the only thing I've found is using cli 1.4.10 (because 1.4.9 has an issue).

jglisson avatar Feb 01 '18 19:02 jglisson

The same problem i faced today.

I found my CLI was not upgraded. I upgraded my CLI globally and locally and it worked fine. So always its good to upgrade our Angular CLI and then try to install packages.

yaswanth89kumar avatar Feb 02 '18 09:02 yaswanth89kumar

Bootstrap v4.0.0 has been released on Jan 18, 2018. So going to v4.0.0-alpha.x cannot be the best solution :-/

mauricewipf avatar Feb 02 '18 19:02 mauricewipf

I did the same as @yaswanth89kumar . I setup my project using angular-cli 1.4.10 and then upgraded the cli to latest.

jglisson avatar Feb 02 '18 20:02 jglisson

Module build failed: ModuleBuildError: Module build failed: BrowserslistError: Unknown browser major

"styles": [
        "../node_modules/bootstrap/scss/bootstrap.scss",
        "styles.scss"
      ]
+

"defaults": {
    "styleExt": "scss",
    "component": {}
  }

hot-fix see in last comment @joseph-schenck

WuglyakBolgoink avatar Feb 07 '18 16:02 WuglyakBolgoink

@angular/cli: 1.7.0-rc.0 solved the problem

zhekaus avatar Feb 08 '18 10:02 zhekaus

While updating to @angular/cli: 1.7.0-rc.0 allowed my code to compile with --prod, all of my font-awesome icons in my app were replaced by squares

bomberblue07 avatar Feb 08 '18 22:02 bomberblue07