1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Error: Module not found: Error: Can't resolve 'xxxxxx' in C:\Path...\fesm2022

Discussão em 'Angular' iniciado por Rafael Leles, Junho 5, 2025.

  1. Rafael Leles

    Rafael Leles Guest

    I'm stuck with this issue and it's driving me a bit crazy. Hope someone can throw me a lifeline here.

    So I have a frontend Angular project.

    In this project, I have a private package (my-shared-lib) that depends on another internal package (my-api-services).

    Both my-shared-lib and my-api-services are correctly installed in my node_modules.

    I can literally see both folders under node_modules — so they are physically there.

    The issue happens when I try to build or serve the project. I get this error:

    Module not found: Error: Can't resolve 'my-api-services' in '.../node_modules/my-shared-lib/fesm2022'


    What confuses me is:

    The my-shared-lib package compiles fine on its own.

    The dependency is there inside node_modules, but somehow Webpack (or Angular compiler or whatever) can't resolve it inside my-shared-lib's compiled files.

    The import is like relative from the perspective of my-shared-lib's build, but it's failing inside fesm2022 dist files.

    This is not some "dependency not installed" issue, because both packages are installed.

    Right now, the only workaround I've found is to force adding my-api-services as a direct dependency of my main project as well. But I feel like I shouldn't have to do that since it's already declared inside my-shared-lib's package.json.

    Feels like something related to package hoisting? Or Angular’s module resolution? Or maybe the way the compiled package is built/published (since it's using fesm2022)? ‍♂️

    We're not using Nx or monorepo tooling, it's all standalone packages.

    Any ideas on what's going on here? Thanks!

    I tried simply building my Angular app after installing both internal packages via npm. Since both my-shared-lib and its dependency my-api-services are properly installed and visible in node_modules, I expected the build to work fine. Instead, I get the "Module not found: Error: Can't resolve 'my-api-services'" even though the package physically exists in node_modules.

    Continue reading...

Compartilhe esta Página