nrwl-nx

How to fix: "The asset path must start with the project source root"?


We have an nrwl/nx project, that we can build on Windows, but it fails on Linux (Ci sytem).

The error is: The /root/dev/apps/dmc-svr/src/assets asset path must start with the project source root: apps\dmc-svr\src

It seems to be a Windows/Linux path issue


Solution

  • The problem was a Windows like path for the sourceRoot property in project.json

    {
      "sourceRoot": "apps\\dmc-svr\\src",
      "targets": {
        "build": {
          "executor": "@nrwl/node:build",
          "options": {
            "assets": [
              "apps/dmc-svr/src/assets",
            ]
          }
        }
      }
    }
    

    the fix is to simply replace the backslash \\ with a slash \: sourceRoot": "apps/dmc-svr/src"

    We guess that this has been generated by some nx-schema.