`path must start with the project source root` 服务中的错误

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

我想在我的 Angular-CLI 项目中使用 jquerybootstrapAngular-CLI 项目在 project/ui 目录中,jquerybootstrap 文件在 project/public/... 路径中。我试图在 angular.json 中引用 jquerybootstrap 文件,但是在 project/ui 目录中的 运行 ng serve 上,我得到错误 - The ./../public/images/favicon.png asset path must start with the project source root。我做错了什么?

angular.json 的片段是

"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"
            ]
          },
//file - angular.json

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

The ./../public/images/favicon.png asset path must start with the project source root

错误指出 favicon.png 的路径必须以项目源根目录开头。 对于默认的 angular 项目,这是 src 文件夹。

如上面的答案所述,请确保您的路径是绝对路径并从 src 开始。