Using angular path causing 'Cannot read properties of undefined'

Discussão em 'Angular' iniciado por Aiwa, Abril 16, 2025.

  1. Aiwa

    Aiwa Guest

    I'm migrating code from an unnecessary library into our /app folder. I've set up path maps for the /app folder. Note this app has been working w/o issue prior to this library migration.

    "compilerOptions": {
    "rootDir": ".",
    ////
    "baseUrl": ".",
    "paths": {
    "@my-app/*": ["src/app/*/index.ts"],
    "@my-lib/*": ["libs/*/src/index.ts"]
    }


    },

    In my src/app/core/index.ts I'm exporting a function createAsyncRequest. Small example of the /src/app/core/index.ts

    [​IMG]

    In my libs/core/src/index.ts I'm exporting the function as a relative path to /src/app/core. So it's loading the same files. Small example of /lib/core/src/index.ts.

    [​IMG]

    There are a handful of files that can import from @my-lib/core, but cannot import from @my-app/core. When importing from @my-app/core I'm getting this console error.

    Uncaught TypeError: Cannot read properties of undefined (reading 'createAsyncRequest')


    Once I switch to @my-lib/core, the error goes away. The only thing I can think of is the order in which the path maps are loaded. But I can't find it.

    Continue reading...

Compartilhe esta Página