简体   繁体   中英

Angular-cli build to production bootstrap error

I'm trying to build an Angular 5 project for deployment to IIS.

When I run the following command:

ng build --prod

I get the following error:

Error in ./node-modules/bootstrap/dist/css/bootstrap.min.css.

Module build failed: BrowserslistError: Unknown browser major.

I read about this error and saw a suggested solution is to upgrade your Angular CLI to 1.7.0 or newer. My CLI version is 1.7.3 and Bootstrap version is 4.0.0.

How do I fix this error so that I can build my solution?

That issue is mentionned here https://github.com/angular/angular-cli/issues/9020 but should normally not occur in angular cli v1.7.0

Try the other workaround:

Remove "../node_modules/bootstrap/dist/css/bootstrap.min.css" from the styles section in .angular-cli.json .

Try including bootstrap's css directly in your global styles.css file

@import "~bootstrap/dist/css/bootstrap.css";

or styles.scss file

@import "~bootstrap/scss/bootstrap";

What version of bootstrap are you using?? I've the same issue with 4.1.2 and I changed it to 4.1.1, finally it's working!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM