question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't resolve modules from custom path

See original GitHub issue

🐞 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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jotatoledocommented, Jun 11, 2019

Provide a repro…

0reactions
angular-automatic-lock-bot[bot]commented, Jun 28, 2020

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript config can't resolve custom paths with ESM enabled
I've been trying to crack this thing down for quite a while now, I want my tsconfig.json paths to be resolved when ESM...
Read more >
Documentation - Module Resolution - TypeScript
Use non-relative paths when importing any of your external dependencies. Module Resolution Strategies. There are two possible module resolution strategies: Node ...
Read more >
Module Resolution - webpack
A resolver is a library which helps in locating a module by its absolute path. A module can be required as a dependency...
Read more >
"Can't resolve '@models/IUser'" when working with typescript ...
Hello all. I'm a bit new to typescript and I looked into the very promising feature of "paths".But when I try to implement...
Read more >
Common TypeScript module problems and how to solve them
Solution 1: Locate the correct directory ; "compilerOptions": ; "baseUrl": ; ".", ; "paths": ; "express": ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found