BrowserslistError: Unknown browser major

后端 未结 9 1612
南旧
南旧 2020-12-15 07:30

I\'m trying to use bootstrap 4 with my angular installation. i\'ve run npm install --save bootstrap@next but i have a break at runtime :

./node_modules/css-l         


        
相关标签:
9条回答
  • 2020-12-15 07:34

    Bootstrap 4 doesn't use CSS anymore. In this version the SCSS is used. So instead of importing '~bootstrap/scss/bootstrap.css', you should import '~bootstrap/scss/bootstrap.scss'.

    0 讨论(0)
  • 2020-12-15 07:35

    Bootstrap new version come which is v4.0.0-beta.2 and your package.json has ^bootstrap4.0.0-alpha.6 so new bootstrap version wants browsers list dependency.

    To run your app remove lastest version tag (^) & run npm install command

    0 讨论(0)
  • 2020-12-15 07:38

    For those still having problems:

    Manually remove the url to bootsrap CSS from angular-cli.json

      "styles":
      [
        **"../node_modules/bootstrap/dist/css/bootstrap.min.css",**
        "../node_modules/font-awesome/css/font-awesome.min.css",    
        "styles.css"
      ]
    
    0 讨论(0)
  • 2020-12-15 07:40

    For Bootstrap 4.0.0 (release) I have to upgrade the CLI to 1.6.5 — and it works!

      "dependencies": {
        "@angular/animations": "^5.0.0",
        "@angular/common": "^5.0.0",
        "@angular/compiler": "^5.0.0",
        "@angular/core": "^5.0.0",
        "@angular/forms": "^5.0.0",
        "@angular/http": "^5.0.0",
        "@angular/platform-browser": "^5.0.0",
        "@angular/platform-browser-dynamic": "^5.0.0",
        "@angular/router": "^5.0.0",
        "@ng-bootstrap/ng-bootstrap": "1.0.0-beta.9",
        "bootstrap": "4.0.0",
        "core-js": "^2.4.1",
        "font-awesome": "^4.7.0",
        "jquery": "^3.2.1",
        "popper.js": "^1.12.9",
        "rxjs": "^5.5.2",
        "zone.js": "^0.8.14"
      },
      "devDependencies": {
        "@angular/cli": "^1.6.5",
        "@angular/compiler-cli": "^5.0.0",
        "@angular/language-service": "^5.0.0",
        "@types/jasmine": "~2.5.53",
        "@types/jasminewd2": "~2.0.2",
        "@types/node": "~6.0.60",
        "codelyzer": "^4.0.1",
        "jasmine-core": "~2.6.2",
        "jasmine-spec-reporter": "~4.1.0",
        "karma": "~1.7.0",
        "karma-chrome-launcher": "~2.1.1",
        "karma-cli": "~1.0.1",
        "karma-coverage-istanbul-reporter": "^1.2.1",
        "karma-jasmine": "~1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~5.1.2",
        "ts-node": "~3.2.0",
        "tslint": "~5.7.0",
        "typescript": "~2.4.2"
      }
    
    0 讨论(0)
  • 2020-12-15 07:46

    The issue could be that you got the latest build with some bug. I noticed that bootstrap@4.0.0-beta.3 is causing this issue, but not bootstrap@4.0.0-beta.2. Check if yours is the same. Try uninstalling that and run something with a specific version.

    npm install bootstrap@4.0.0-alpha.6

    This resolved my problem.

    0 讨论(0)
  • 2020-12-15 07:47

    I've upgraded to Angular CLI 1.7.x and it started working fine. I recommend this solution. I mean upgrading the Angular CLI and it should work for you!

    Another workaround is deleting the below lines from node_modules/bootstrap/package.json

    "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"
    ],
    
    0 讨论(0)
提交回复
热议问题