angular-cli: 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
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 60
- Comments: 94 (8 by maintainers)
Links to this issue
Commits related to this issue
- test: pin bootstrap version in e2e test Related to #9020, https://travis-ci.org/angular/angular-cli/jobs/322676874#L3792 — committed to filipesilva/angular-cli by filipesilva 7 years ago
- fix(@angular/cli): update autoprefixer Fix #9020, related to https://travis-ci.org/angular/angular-cli/jobs/322676874#L3792 — committed to filipesilva/angular-cli by filipesilva 7 years ago
- fix(@angular/cli): update autoprefixer Fix #9020, related to https://travis-ci.org/angular/angular-cli/jobs/322676874#L3792 — committed to angular/angular-cli by filipesilva 7 years ago
- Fixing issue with bootstrap beta.3 See also https://github.com/angular/angular-cli/issues/9020 — committed to joaopgrassi/env-guard by joaopgrassi 6 years ago
- Workaroud for bug angular/angular-cli#9020 — committed to tomek199/elo-rating by tomek199 6 years ago
- fix(@angular/cli): update autoprefixer Fix #9020, related to https://travis-ci.org/angular/angular-cli/jobs/322676874#L3792 — committed to angular/angular-cli by filipesilva 7 years ago
- Update Dependencies - Use path.sep instead of / - Travis build will fail [#9020](https://github.com/angular/angular-cli/issues/9020) — committed to ascii-dresden/asciii-gui by V1ncNet 6 years ago
- Change the way Bootstrap is imported to fix build issues See: https://github.com/angular/angular-cli/issues/9020 — committed to release-engineering/mbs-ui by mprahl 6 years ago
- remove caret from bootstrap to try and solve : https://github.com/angular/angular-cli/issues/9020 — committed to blabadi/nutritionTracker by blabadi 6 years ago
- fix(@angular/cli): update autoprefixer Fix #9020, related to https://travis-ci.org/angular/angular-cli/jobs/322676874#L3792 — committed to d2clouds/speedray-cli by filipesilva 7 years ago
Did you tried this? Same error and fixed by,
I was facing same issue. I downgraded bootstrap with following steps. Uninstall bootstrap@4.0.0-beta.3: npm uninstall bootstrap --save Then installed bootstrap@4.0.0-beta.2: npm install bootstrap@4.0.0-beta.2 --save
I did not remove ^ because package-lock.json will handle it.
Step 1. Inside
.angular-cli.json
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.
bootstrap’s 4.0.0 beta 3 came out today. Might have to downgrade to their beta 2 again to make it work. I am running into the same issue.
You can use Bootstrap 4 beta 3, but first edit package.json in node_modules/bootstrap:
“browserslist”: [ “last 1 major version”, <----- delete this line “>= 1%”, <----- delete this line “Chrome >= 45”, “Firefox >= 38”, “Edge >= 12”, “Explorer >= 10”, “iOS >= 9”, “Safari >= 9”, “Android >= 4.4”, “Opera >= 30” ],
@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 filestyle.css
tostyle.scss
and add@import "../node_modules/bootstrap/scss/bootstrap.scss"
to the top of the file.@ekwebster
"bootstrap": "^4.0.0-beta.2"
the caret here means it will update you to the most recent version, just tryyarn upgrade bootstrap@4.0.0-beta.2
ornpm update bootstrap@4.0.0-beta.2
CLI 1.6.4 does not fix the problem.
The issue seems to be caused by this section of bootstrap’s
package.json
fileThe
autoprefixer
plugin uses this list and unless you have a version 7.0 or higher it does not support thelast n major version
syntax.Upgrading
autoprefixer
should fix the issue.Removing the caret ‘^’ did solve the problem
Running into the same problem here.
I’m using bootstrap
4.0.0
with CLI v1.6.3
.This worked for me.
This should be fixed on Angular CLIs side in the next release (
1.6.4
). That should be next week.Changed cli version to 1.7.0 in package.json. Working as expected now.
I have the same error
The error persist only in production builds.
I have fixed my package.json to:
“bootstrap”: “4.0.0-beta.2” If you have an app at production environment I think the best practice is to use a stable and fixed version.
Steps:
1-Remove /node_modules 2-Fix the package.json file 3-Execute npm install 4-Enjoy!
Temp Fix
Should work
@angular/cli: 1.7.0-rc.0
solved the problemBootstrap v4.0.0 has been released on Jan 18, 2018. So going to v4.0.0-alpha.x cannot be the best solution 😕
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.
Have the same problem.
I just started to learn Angular, I don’t need bootstrap 4. I just want the simplest solution to make my project alive again. So I downgraded a bootstrap.
package.json
file I changed to"bootstrap": "3.3.7",
npm install
ng serve --open
Running into this issue as well trying to use the latest angular-cli “1.6.3” with the latest bootstrap “4.0.0-beta.2”.
Hi all! I read all of yours comment and after I follow most of logs that the npm leave on my console (after a boring fight with bootstrap), so I uninstall and reinstall: npm uninstall bootstrap --save subsequently npm install bootstrap@4.0.0-beta.2 --save so I see in the console: this warning:
I follow the suggest, so npm install jquery@1.9.1 --save and npm install popper.js@^1.12.3 --save finally: npm install and ng serve and IT WORK!!!
I changed the path to bootstrap.scss @import “~ bootstrap / scss / bootstrap.scss”; in the styles.scss file. And solved this problem Also adding packages node-sass and sass-loader
i have removed following two line from bootstrap/package.json file
“last 1 major version”, “>= 1%”,
Installing angular cli 1.6.6 solve the problem for me!
cli 1.7.0-beta.1 fixes the issue when using the latest released bootstrap (4.0.0) (not beta) as well.
Simply upgrading to @angular/cli@1.7.0-beta.1 solved the problem for me, like @Jimeh87 proposed.
@filipesilva Yes using
@angular/cli@1.7.0-beta.0
fix the issue.CLI 1.6.4 fixed the problem for me.
still happening - also today had to specify beta 2 as 3 will produce same error as above
This does seem to be related to
bootstrap@4.0.0-beta.3
, and is also causing failures in our CI (https://travis-ci.org/angular/angular-cli/jobs/322676874).update to ng cli 1.6.8 in project and global. works with bootstrap 4.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.
Development builds were fixed. Production builds required additional changes which were already present but are only available in 1.7 (currently in beta). The stylesheet optimization pipeline was rewritten providing both increased performance and fixing multiple underlying issues. This however cannot be published in a patch release hence its presence in 1.7 and not 1.6.x.
Just upgrade from 4.0.0-beta to 4.0.0 and experienced this problem with ng serve. Went back to 4.0.0-beta and ng serve is ok. This issue shouldn’t be closed if it’s a cli issue.
@jameskentTX provided me with the workaround. Except the filename is package.json in the node_modules/bootstrap folder for me.
I have the same problem too.
@joseph-schenck solution solved my problem
I did the same as @yaswanth89kumar . I setup my project using angular-cli 1.4.10 and then upgraded the cli to latest.
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).
1.6.6 does not solves the issue !
I tried Bootstrap@4.0.0 with Angular CLI 1.6.6 (local and global), and it worked fine.
Just globally update your angular/cli before starting a new project: npm i -g @angular/cli It works with beta 3, too !
I upgraded to
@angular/cli@1.7.0-beta.1
, created a new project, addedbootstrap@^4.0.0
and I was able to start the app withbootstrap.min.css
plumbed in by adding it as an@import
to mystyles.css
. I was also able to start my app by plumbing it in via the.angular-cli.json
by adding it to the styles.A gotcha here would be to make sure you upgrade your global and your app to @angular/cli to 1.7.0-beta.1 and double check that it actually upgraded by running ng --version (mine didn’t so I had to manually remove and reinstall it for some reason).
Can you try
@angular/cli@1.7.0-beta.0
instead please? See https://github.com/angular/angular-cli/issues/9029#issuecomment-357267439 for more details.Hi! I upgraded to release
1.6.4
, but i’m always facing the problem, usingbootstrap@4.0.0-beta.3
. Unfortunately I need to use that version of bootstrap because it fixes another problem. I’ll try the workaround proposed some days ago, but I hope in a “cleaner” solution. Thank you for the support.A workaround here on SO (https://stackoverflow.com/questions/48034051/bootstrap-4-beta-3-throws-error-with-angular-cli). Will need to re-run each time you upgrade, until the next version of CLI that updates autoprefixer to latest…
I downgraded bootstrap to “bootstrap@4.0.0-beta.2” and the app back to work again