koque
koque

Reputation: 2256

Link to bootstrap not working in Angular 2

In index.html as shown below, I am trying to link to bootstrap.css located in node_modules folder but getting an error.

Folder structure of application:

ecommerce-app/node_modules

ecommerce-app/src/app/index.html

In index.html, all of the following references to bootstrap.css produced errors:

<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css">

<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.css">

<link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.css">

This is the error: GET http://localhost:3000/node_modules/bootstrap/dist/css/bootstrap.css NOT FOUND

Upvotes: 2

Views: 806

Answers (1)

SrAxi
SrAxi

Reputation: 20005

If you are using Angular-CLI, add this to your angular-cli.json:

"apps": [
    {
      "styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.css"
      ],

Upvotes: 2

Related Questions