Skip to content

Can't resolve modules from custom path #30978

@tbnovaes

Description

@tbnovaes

🐞 bug report

Description

When trying to serve the app using custom paths on tsconfig.json for some libs I created everything works fine, however, when trying to build it using AOT, I get multiple errors:

ERROR in ./src/app/app.module.ngfactory.js
Module not found: Error: Can't resolve 'some_module' in 'some_path '

Works fine when AOT is set to false.

Additional Information

Here is my tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": {
      //Env
      "@env/*": ["src/environments/*"],

      //Libs
      "@lib/pipes": ["dist/pipes"],
      "@lib/pipes/*": ["dist/pipes/*"],
      "@lib/utils": ["dist/utils"],
      "@lib/utils/*": ["dist/utils/*"],
      "@lib/directives": ["dist/directives"],
      "@lib/directives/*": ["dist/directives/*"],
      "@lib/models": ["dist/models"],
      "@lib/models/*": ["dist/models/*"],
      "@lib/websocket": ["dist/websocket"],
      "@lib/websocket/*": ["dist/websocket/*"],
      "@lib/intl-phone-input": ["dist/intl-phone-input"],
      "@lib/intl-phone-input/*": ["dist/intl-phone-input/*"]
    }
  }
}

🌍 Your Environment

**Angular Version:**
Angular CLI: 8.0.0
Node: 12.3.1
OS: darwin x64
Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.800.0
@angular-devkit/core         8.0.0
@angular-devkit/schematics   8.0.0
@schematics/angular          8.0.0
@schematics/update           0.800.0
rxjs                         6.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compilerfreq1: low

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions