BrowserslistError: Unknown browser major at error
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
@alanreji i tried ur solution and it worked perfectly ... thnx
- change the style.css to scss (and all the css to scss also).
- @import "../node_modules/bootstrap/scss/bootstrap.scss"; --> put this in the first line of style.scss
- remove the bootstrap.css or bootstrap.min.css at the angular-cli.json ng build --prod everything work accordingly. Thank guys.....
thank you all for your help, the problem is solved!
@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?
Installing angular cli 1.6.6 solve the problem for me!
1.6.6 does not solves the issue !
@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 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 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.
@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?
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.
We are required to use Angular 4 because of LTS.
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.
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).
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.
Bootstrap v4.0.0 has been released on Jan 18, 2018. So going to v4.0.0-alpha.x cannot be the best solution :-/
I did the same as @yaswanth89kumar . I setup my project using angular-cli 1.4.10 and then upgraded the cli to latest.
- angular/[email protected]
- bootstrap v4.0.0
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
@angular/cli: 1.7.0-rc.0 solved the problem
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