`path must start with the project source root` error in ng serve

Manu Chadha picture Manu Chadha · Jul 24, 2018 · Viewed 7.8k times · Source

I want to use jquery and bootstrap in my Angular-CLI project. The Angular-CLI project is in project/ui directory and the jquery and bootstrap files are in project/public/... path. I am trying to refer to the jquery and bootstrap files as follows in angular.json but on running ng serve in project/ui directory, I am getting error - The ./../public/images/favicon.png asset path must start with the project source root. What am I doing wrong?

The snippet of angular.json is

"projects": {
    "ui": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "./../public/images/favicon.png"
            ],
            "styles": [
              "src/styles.css",
              "./../public/stylesheets/common/css-reset.css",
              "./../public/stylesheets/common/common-styles.css",
              "./../public/stylesheets/common/vendor/bootstrap/bootstrap.css"
            ],
            "scripts": [
              "./../public/javascripts/common/vendor/jquery/jquery-3.2.1.js",
              "./../public/javascripts/common/vendor/bootstrap/bootstrap.js"
            ]
          },

Answer

md_salm picture md_salm · Mar 9, 2019
//file - angular.json

"assets": [
   "src/assets",
   "src/favicon.ico"    //This worked for me.
]