Morilly0408020
Morilly0408020

Reputation: 11

Angular4/Typescript/Bootstrap-can't compile

I get the following error:

ERROR in multi ./node-modules/bootstrap/dist/css/bootstrap.min.css ./src/styles.css Module not found: Error: Can't resolve

Module not found: Error: Can't resolve '/Users/hansdeschinkel/VSCode/Resto/node-modules/bootstrap/dist/css/bootstrap.css' in '/Users/hansdeschinkel/VSCode/Resto/node_modules/@angular/cli/models/webpack-configs'

"styles": [
    "../node-modules/bootstrap/dist/css/bootstrap.min.css",
    "styles.css"
  ],

I have saved bootstrap 3.3.7 in my node_modules. I have also added it to my angular/cli.json folder: I am using VSCode

Upvotes: 1

Views: 1694

Answers (3)

Hanna Kogut
Hanna Kogut

Reputation: 430

You should change the path from

    "styles": [
    "../node-modules/bootstrap/dist/css/bootstrap.min.css",
    "styles.css"
  ],

to

    "styles": [
    "/node-modules/bootstrap/dist/css/bootstrap.min.css",
    "styles.css"
  ],

Upvotes: 0

Ashish Singh Rawat
Ashish Singh Rawat

Reputation: 1593

For Angular 6

   "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"
  ]

Upvotes: 0

Darshita
Darshita

Reputation: 746

If your styels.css in src folder and bootstrap.min.css in node_modules folder then change your code as shown below :

styles: [
       'node_modules/bootstrap/dist/css/bootstrap.css',
       'src/styles.css'
]

In angular-cli to render css file give absolute path not relative path.

Upvotes: 3

Related Questions