Error 404 when loading resources from the node_modules folder with Angular2

0

I have an application using angular 4 that is giving 404 error when trying to load css , font and javascript resources from the node_modules folder.

So it's in my index.html:

<link href="node_modules/font-awesome/css/font-awesome.min.css" />
<link href="node_modules/simple-line-icons/css/simple-line-icons.css" />
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css" />
<link href="node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css" />

My angular-cli is updated and I used to load normally.

From what I've been looking for, I read that I needed the "moduleResolution": "node" setting in tsconfig.json. It was already there and it is not working.

What should I do?

    
asked by anonymous 05.05.2017 / 14:56

1 answer

0

To insert third-party libraries like font awesome and bootstrap you should modify your .angular-cli.json file in your project when build is done > files are included.

    "styles": [
        "styles.css",
        "../node_modules/font-awesome/css/font-awesome.min.css",
        "../node_modules/simple-line-icons/css/simple-line-icons.css"
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "../node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css"
    ],
    "scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "../node_modules/bootstrap/dist/css/bootstrap.min.css"
    ],

In your case, just add the paths of the css files required for the project to the% field, and remove them from style to leave the angular load of these files.

    
01.06.2017 / 00:55