0
votes

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?

2
Try to delete caret ‘^’ of the bootstrap entry in the package.json - ForestG
Have you attempted updating the Angular CLI globally? github.com/angular/angular-cli#updating-angular-cli - ShellNinja
I tried to delete the caret - still not working. @ForestG - KonRow
My global cli is up to date (1.7.3) and I run the build from global cli. @ShellNinja - KonRow
How do you include bootstrap's css? - David

2 Answers

5
votes

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";
0
votes

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!