2
votes

im trying to start a project with Angular, but I cannot get further because of error:

"ERROR in multi ./src/styles.css ./node_modules/bootstrap/dist/css/bootstrap.min.css Module not found:"

The dependencies are as follow:

"dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26",
    "bootstrap":  "3.3.7"
}

angular.json (relevant piece):

    "styles": [
        "src/styles.css"
    ],
    "scripts": []
},

devDependencies:

"devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.8",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
}

I have tried all solutions from stackoverflow but to no avail. I have tried:

"styles": [
      "src/styles.css",
      "node_modules/bootstrap/dist/css/bootstrap.css"
    ],
    "scripts": ["../node_modules/jquery/dist/jquery.js",
      "node_modules/bootstrap/dist/js/bootstrap.bundle.js"
  ]`

I have tried to combine different versions of applications (e.g. angular 6, bootstrap 4 etc.)

I have tried to remove node_modules/bootstrap/dist/css/bootstrap.css from package and have it imported in styles.css

Nothing works, now I'm out of ideas, facing a despair and defeat already on 33 page of book "Pro Angular" by Adam Freeman. Maybe someone here has experienced this problem and has a working solution other that mentioned above?

2
This should work , looks like <base href='/'> in index.html is missing . - eduPeeth

2 Answers

0
votes

You could try to add it to index.html instead. Try adding this at the bottom of your <body> tag:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

If that doesn't work, try to restart npm start or ng serve. Sometimes, when you modify the angular.json you have to do it.

0
votes

try

"styles": [
      "node_modules/bootstrap/dist/css/bootstrap.min.css",
      "src/styles.css"

I read that bootstrap should be first and then styles.css. I also add "min.css" but I do not remember now whether it should contain it