Skip to content

tsconfig "paths" config is not recognized #3837

Closed

Description

@lehresman

Mac OSX Sierra
angular-cli version 1.0.0-beta.24

I'm trying to configure things so I don't have to use ugly (and brittle) relative paths when including modules from my own project. I modified tsconfig.json to include:

  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@app/*": "app/*"
    },
   ...

And that works great for TypeScript.

However, "ng serve" is throwing this error:

ERROR in ./src/app/content/content.component.ts
Module build failed: Error: /Users/lehresman/Projects/gazelle-ui/src/app/content/content.component.ts (2,29): Cannot find module '@app/models/client.model'.)
    at _checkDiagnostics (/Users/lehresman/Projects/gazelle-ui/node_modules/@ngtools/webpack/src/loader.js:116:15)
    at /Users/lehresman/Projects/gazelle-ui/node_modules/@ngtools/webpack/src/loader.js:141:17
 @ ./src/app/app.module.ts 17:0-65
 @ ./src/main.ts
 @ multi main

I've discovered that Webpack has configuration options for this, but I can't figure out how to configure Webpack through Angular-CLI to support this. Is this a bug, or is this feature not exposed?

Activity

  1. duncanwerner commented on Aug 14, 2017

    @duncanwerner

    Maybe related to #7341, although for me --aot does not work either.

  2. glebinsky commented on Aug 16, 2017

    @glebinsky

    I'm having an issue where the app builds and runs fine but non-relative paths are not resolved in VS Code. Here's my setup:

    ├── @angular/animations@4.3.4
    ├── @angular/cli@1.3.0
    ├── @angular/common@4.3.4
    ├── @angular/compiler@4.3.4
    ├── @angular/compiler-cli@4.3.4
    ├── @angular/core@4.3.4
    ├── @angular/forms@4.3.4
    ├── @angular/http@4.3.4
    ├── @angular/language-service@4.3.4
    ├── @angular/platform-browser@4.3.4
    ├── @angular/platform-browser-dynamic@4.3.4
    ├── @angular/router@4.3.4
    ├── @ngrx/effects@4.0.2
    ├── @ngrx/store@4.0.2
    ├── @types/jasmine@2.5.53
    ├── @types/jasminewd2@2.0.2
    ├── @types/node@6.0.86
    ├── codelyzer@3.1.2
    ├── core-js@2.5.0
    ├── jasmine-core@2.6.4
    ├── jasmine-spec-reporter@4.1.1
    ├── karma@1.7.0
    ├── karma-chrome-launcher@2.1.1
    ├── karma-cli@1.0.1
    ├── karma-coverage-istanbul-reporter@1.3.0
    ├── karma-jasmine@1.1.0
    ├── karma-jasmine-html-reporter@0.2.2
    ├── protractor@5.1.2
    ├── rxjs@5.4.3
    ├── ts-node@3.2.2
    ├── tslint@5.3.2
    ├── typescript@2.4.2
    └── zone.js@0.8.16
    

    tsconfig.json

    {
      "compileOnSave": false,
      "compilerOptions": {
        "baseUrl": "./src",
        "outDir": "./dist/out-tsc",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es5",
        "typeRoots": [
          "node_modules/@types"
        ],
        "lib": [
          "es2017",
          "dom"
        ]
      }
    }
    

    tsconfig.app.json

    {
      "extends": "../tsconfig.json",
      "compilerOptions": {
        "baseUrl": "./",
        "paths": {
          "*": [
            "*",
            "app/*",
            "environments/*"
          ]
        },
        "outDir": "../out-tsc/app",
        "module": "es2015",
        "types": []
      },
      "exclude": [
        "test.ts",
        "**/*.spec.ts"
      ]
    }
    
  3. duncanwerner commented on Aug 17, 2017

    @duncanwerner

    I still haven't figured this out completely, but I have a workaround. This may be a windows-specific problem. This does not work:

        "baseUrl": ".",
        "paths": {
          "@local/*": [
            "../local_modules/*"
          ]
        }
    

    This does work (baseURL moves up one directory, paths moves down):

        "baseUrl": "..",
        "paths": {
          "@local/*": [
            "local_modules/*"
          ]
        }
    

    Hope that helps someone. I may try to track down the specific problem, but it's not a typescript problem; trying a generic tsc compile with a different config, both of these work.

  4. glebinsky commented on Aug 18, 2017

    @glebinsky

    @duncanwerner I used your idea and got it to work on Mac. Seems like the builder uses tsconfig.app and linter(?) uses tsconfig

    tsconfig:

    {
      "compileOnSave": false,
      "compilerOptions": {
        "baseUrl": ".",
        "paths": {
          "*": [
            "*",
            "src/app/*",
            "src/environments/*"
          ]
        },
        "outDir": "./dist/out-tsc",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "target": "es5",
        "typeRoots": [
          "node_modules/@types"
        ],
        "lib": [
          "es2017",
          "dom"
        ]
      }
    }
    

    tsconfig.app

    {
      "extends": "../tsconfig.json",
      "compilerOptions": {
        "baseUrl": ".",
        "paths": {
          "*": [
            "*",
            "app/*",
            "environments/*"
          ]
        },
        "outDir": "../out-tsc/app",
        "module": "es2015",
        "types": []
      },
      "exclude": [
        "test.ts",
        "**/*.spec.ts"
      ]
    }
    
  5. Parziphal commented on Aug 29, 2017

    @Parziphal

    I seems like the error was that tsconfig.app.json was overwriting the baseUrl option of the root-level tsconfig.json, setting it to ./ (instead of just .). Once I removed that option from that file, the build was successful.

  6. duncanwerner commented on Aug 29, 2017

    @duncanwerner

    tsconfig.app.json extends tsconfig.json, so any values you define in the former will override values in the latter, at least for app configuration.

  7. Parziphal commented on Aug 29, 2017

    @Parziphal

    Yeah, I mean the error was that I wasn't aware of the overwriting, not that "the file is overwriting my config, that's an error, how dare that file!".

    Now I just found a little thing. The IDE (vscode) doesn't show any suggestions while I type a path using the alias (so it won't autocomplete, I have to write the full path). Is there a way to fix this? Not that it's too important but... if it can be fixed it'd be nice.

    image

  8. duncanwerner commented on Aug 29, 2017

    @duncanwerner

    vscode (or presumably any other editor, but that's what I use as well) uses the root tsconfig.json. so make sure that aliases in that file are correct relative to the location of that file. you may also have to close/open files or even the whole editor to get it to refresh the cache.

  9. Parziphal commented on Aug 29, 2017

    @Parziphal

    Does it autocomplete to you? Because it doesn't here. I restarted the editor, and I made sure the path is correctly relative to the root tsconfig.json.
    Just to make it clear, the alias is recognized and works if I write the complete path, but the ide doesn't show any suggestions for autocompletion.

  10. duncanwerner commented on Aug 29, 2017

    @duncanwerner

    Sorry, I misunderstood. It does not autocomplete aliased paths. File a feature request over at the vscode repo.

  11. ivanguimam commented on Apr 9, 2018

    @ivanguimam

    I have a problem similar to this when I run the tests E2E

    Angular CLI version:

    Angular CLI: 1.7.3
    Node: 8.9.1
    OS: linux x64
    Angular: 5.2.9
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    @angular/cli: 1.7.3
    @angular-devkit/build-optimizer: 0.3.2
    @angular-devkit/core: 0.3.2
    @angular-devkit/schematics: 0.3.2
    @ngtools/json-schema: 1.2.0
    @ngtools/webpack: 1.10.2
    @schematics/angular: 0.3.2
    @schematics/package-update: 0.3.2
    typescript: 2.7.2
    webpack: 3.11.0
    

    tsconfig.json

    {
        "compileOnSave": false,
        "compilerOptions": {
            "outDir": "./dist/out-tsc",
            "sourceMap": true,
            "declaration": false,
            "moduleResolution": "node",
            "emitDecoratorMetadata": true,
            "experimentalDecorators": true,
            "target": "es5",
            "typeRoots": [
                "node_modules/@types"
            ],
            "baseUrl": ".",
            "paths": {
                "@service/*": ["src/app/shared/service/*"],
                "@directive/*": ["src/app/shared/directive/*"],
                "@component/*": ["src/app/shared/component/*"],
                "@entity/*": ["src/app/entity/*"],
                "@enum/*": ["src/app/enum/*"],
                "@environment/*": ["src/environments/*"],
                "@shared/*": ["src/app/shared/*"],
                "@guest/*": ["src/app/guest/*"],
                "@dashboard/*": ["src/app/dashboard/*"],
                "@validator/*": ["src/app/validator/*"],
                "@interface/*": ["src/app/interface/*"],
                "@mask/*": ["src/app/mask/*"],
                "@pipe/*": ["src/app/shared/pipe/*"],
                "@e2e/*": ["e2e/*"],
                "@factory/*": ["factory/*"],
                "@mock/*": ["mock/*"],
                "@database/*": ["database/*"]
            },
            "lib": [
                "es2017",
                "dom"
            ]
        }
    }
    

    tsconfig.e2e.json

    {
        "extends": "../tsconfig.json",
        "compilerOptions": {
            "outDir": "../out-tsc/e2e",
            "module": "commonJS",
            "types": [
                "jasmine",
                "jasminewd2",
                "node"
            ]
        }
    }
    

    Error: Error: Error: Cannot find module '@e2e/utils/utils'

  12. dabruns commented on Jun 22, 2018

    @dabruns

    I have the same problem as @ivanguimam mentioned, has anyone solved this? My app works fine but my e2e tests crashing every time when I try to start them with path variables.

  13. Bengreen commented on Aug 23, 2018

    @Bengreen

    I am having trouble getting paths to work when building packages. ie in the tsconfig.lib.json
    I have added:

    "paths": {"@lib/*": ["lib/*"], },
    

    to tsconfig.lib.json and then try to utilise it with a path such as

    import { CrossfilterDataComponent } from "@lib/bids/crossfilter-data/crossfilter-data.component";
    

    the target file is src/lib/bids/crossfilter-data/crossfilter-data.component.ts

  14. alan-agius4 commented on Aug 23, 2018

    @alan-agius4
    Collaborator

    @Bengreen, may I suggest you open a new issue with a small reproduction if you feel it’s a bug. That said when building packages you should not reference files like you showed above but rather the entrypoint aka the library
    https://github.com/dherges/ng-packagr/blob/master/docs/secondary-entrypoints.md

  15. YuriiZadorozhnyi commented on Sep 18, 2018

    @YuriiZadorozhnyi

    @ivanguimam I have the same problem. Did you find the solution?

  16. ivanguimam commented on Sep 18, 2018

    @ivanguimam

    @YuriiZadorozhnyi no I just left the E2E tests aside because I had a deadline to deliver the project and could not continue to run after a solution to this problem...

  17. seabass223 commented on Nov 5, 2018

    @seabass223

    is this broken for anybody in Angular 7? I don't see paths anymore in https://angular.io/api/core/CompilerOptions
    I'm getting compilation errors with ng serve on all of the paths that I had in tsconfig.json

  18. Fiontan commented on Nov 6, 2018

    @Fiontan

    Reading all the above and seeing all related closed issue and yet it still seems to be a thing in Angular 7 as @seabass223 has mentioned

  19. seabass223 commented on Nov 7, 2018

    @seabass223

    I found that if I incorrectly change one of my path values to a string rather than an array,

     "paths": {
          "@services/*": ["app/modules/core/services/"],
    

    to

     "paths": {
          "@services/*": "app/modules/core/services/",
    

    during ng serve I get the error
    ERROR in error TS5063: Substitutions for pattern '@services/*' should be an array.
    so we know it's still trying to do substitutions.
    Ok so I change it back and try ng serve --verbose which gives me

    C:\Users\MyWindowsUser\source\node_modules doesn't exist or is not a directory
          C:\Users\MyWindowsUser\node_modules doesn't exist or is not a directory
          C:\Users\node_modules doesn't exist or is not a directory
          C:\node_modules doesn't exist or is not a directory
          looking for modules in C:\Users\MyWindowsUser\source\repos\MyProject\client\web\node_modules
          using description file: C:\Users\MyWindowsUser\source\repos\MyProject\client\web\package.json (relative path: ./node_modules)
              Field 'browser' doesn't contain a valid alias configuration
              using description file: C:\Users\MyWindowsUser\source\repos\MyProject\client\web\package.json (relative path: ./node_modules/@services)
                no extension
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\Users\MyWindowsUser\source\repos\MyProject\client\web\node_modules\@services doesn't exist
                .ts
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\Users\MyWindowsUser\source\repos\MyProject\client\web\node_modules\@services.ts doesn't exist
                .tsx
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\Users\MyWindowsUser\source\repos\MyProject\client\web\node_modules\@services.tsx doesn't exist
                .mjs
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\Users\MyWindowsUser\source\repos\MyProject\client\web\node_modules\@services.mjs doesn't exist
                .js
                  Field 'browser' doesn't contain a valid alias configuration
                  C:\Users\MyWindowsUser\source\repos\MyProject\client\web\node_modules\@services.js doesn't exist
                as directory
                  C:\Users\MyWindowsUser\source\repos\MyProject\client\web\node_modules\@services doesn't exist
    [C:\Users\MyWindowsUser\source\repos\MyProject\client\web\src\@services]
    [C:\Users\MyWindowsUser\source\repos\MyProject\client\web\src\@services.ts]
    [C:\Users\MyWindowsUser\source\repos\MyProject\client\web\src\@services.tsx]
    [C:\Users\MyWindowsUser\source\repos\MyProject\client\web\src\@services.mjs]
    [C:\Users\MyWindowsUser\source\repos\MyProject\client\web\src\@services.js]
    

    It looks like it's looking in node_models for @service instead of trying to map it.
    I'm still digesting this all, but I'm curious about what this part means

    using description file: C:\Users\MyWindowsUser\source\repos\MyProject\client\web\package.json (relative path: ./node_modules)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: C:\Users\MyWindowsUser\source\repos\MyProject\client\web\package.json (relative path: ./node_modules/@services)
    no extension
    Field 'browser' doesn't contain a valid alias configuration

    any help is much appreciated in solving this.

  20. clydin commented on Nov 7, 2018

    @clydin
    Member

    Try: "@services/*": ["app/modules/core/services/*"],

  21. seabass223 commented on Nov 8, 2018

    @seabass223

    I think I've got it fixed now

    Setup

    • ng new path-alias-test
    • cd path-alias-test
    • npm i -g npm-check-updates && ncu -a && npm i (upgrades all packages to latest)
    • ng g s services/a
    • ng g s services/b
    • ng g s services/sub/c
    • in tsconfig.json compilerOptions node
    "baseUrl": "src",
    "paths":{
       "@services/*":["app/services/*"]
    },
    
    • in app.component.ts
    import { AService } from '@services/a.service';
    import { BService } from '@services/b.service';
    import { CService } from '@services/sub/c.service';
    ...
    export class AppComponent {
      title = 'app';
      a: AService;
      b: BService;
      c: CService;
    }
    
    
    • ng serve

    The above compiles fine with no errors.

    When we add barrel files in order to simplify our imports

    src/app/service/index.ts

    export * from './sub';
    export * from './a.service';
    export * from './b.service';
    

    src/app/service/sub/index.ts

    export * from './c.service';
    

    and change app.component.ts imports to

    import { AService, BService } from '@services/';
    import { CService } from '@services/sub';
    
    • ng serve
      gives us ERROR in src/app/app.component.ts(2,36): error TS2307: Cannot find module '@services/'.
      Why are we getting this error now?

    Resolution

    If we remove the final * in tsconfig.json paths

    "paths":{
       "@services/*":["app/services/"]
    },
    
    • ng serve
      now compiles fine with no errors. I'm not sure why we had to change ["app/services/*"] to ["app/services/"] for concise imports to work with barrel(index.ts) files.
  22. clydin commented on Nov 8, 2018

    @clydin
    Member

    import { AService, BService } from '@services/'; -> import { AService, BService } from '@services';
    Try removing the trailing slash from the import and adding either an additional path mapping just @services or try changing the path mapping to "@services*":["app/services*"].

    Also please see here for details on TypeScript module resolution and path mapping: https://www.typescriptlang.org/docs/handbook/module-resolution.html

  23. seabass223 commented on Nov 8, 2018

    @seabass223

    thanks for the response. I tried "@services*":["app/services*"] but that didn't work either. I'll give the module-resolution handbook a good read.

  24. MarcosMeli commented on Nov 11, 2018

    @MarcosMeli

    Solved the problem in Angular 7 adding the paths to both tsconfig files

    • paths in tsconfig.json helps vscode to works and with intellisense
    • paths in tsconfig.app.json is also needed for angular

    tsconfig.json

    image

    tsconfig.app.json

    image

    and the intellisense works great

    image

  25. seabass223 commented on Nov 12, 2018

    @seabass223

    that does work great since your mapping directly to individual files, but may still fail when using the * wildcard.
    After reading the Module Resolution page, I ran tsc --traceResolution

    'baseUrl' option is set to 'C:/Users/WindowsUsers/source/repos/path-alias-test/src', using this value to resolve non-relative module name '@services'.
    'paths' option is specified, looking for a pattern to match module name '@services'.
    Module name '@services', matched pattern '@services'.
    Trying substitution 'app/services/*', candidate module location: 'app/services/*'.
    Loading module as file / folder, candidate module location 'C:/Users/WindowsUsers/source/repos/path-alias-test/src/app/services/*', target file type 'JavaScript'.
    File 'C:/Users/WindowsUsers/source/repos/path-alias-test/src/app/services/*.js' does not exist.
    File 'C:/Users/WindowsUsers/source/repos/path-alias-test/src/app/services/*.jsx' does not exist.
    Directory 'C:/Users/WindowsUsers/source/repos/path-alias-test/src/app/services/*' does not exist, skipping all lookups in it.
    Loading module '@services' from 'node_modules' folder, target file type 'JavaScript'.
    Directory 'C:/Users/WindowsUsers/source/repos/path-alias-test/src/app/node_modules' does not exist, skipping all lookups in it.
    Directory 'C:/Users/WindowsUsers/source/repos/path-alias-test/src/node_modules' does not exist, skipping all lookups in it.
    File 'C:/Users/WindowsUsers/source/repos/path-alias-test/node_modules/@services.js' does not exist.
    File 'C:/Users/WindowsUsers/source/repos/path-alias-test/node_modules/@services.jsx' does not exist.
    Directory 'C:/Users/WindowsUsers/source/repos/node_modules' does not exist, skipping all lookups in it.
    Directory 'C:/Users/WindowsUsers/source/node_modules' does not exist, skipping all lookups in it.
    Directory 'C:/Users/WindowsUsers/node_modules' does not exist, skipping all lookups in it.
    Directory 'C:/Users/node_modules' does not exist, skipping all lookups in it.
    Directory 'C:/node_modules' does not exist, skipping all lookups in it.
    ======== Module name '@services' was not resolved. ========
    

    I was able to fix it finally by setting my tsconfig (tsconfig.app.json has no baseUrl or Paths because it only extends tsconfig)

     "baseUrl": "src",
      "paths":{
          "@services":["app/services/"]
       },
    

    and appropriately using index.ts files just like node_modules/@angular does.
    The * were the culprit.

  26. localyost3000 commented on Nov 16, 2018

    @localyost3000

    I'm having a similar problem after updating to angular 7.0.4. I do not use angular cli for my project, but I am convinced it is ngtools/webpack causing the problem.

    The relevant portions of my tsconfig look like this:

            "baseUrl": ".",
            "paths": {
                "@components/*": ["components/*", "components/"],
                "@directives/*": ["directives/*", "directives/"],
                "@core/*": ["core/*", "core/"],
                "@guards/*": ["guards/*", "guards/"],
                "@models/*": ["models/*", "models/"],
                "@modules/*": ["modules/*", "modules/"],
                "@pipes/*": ["pipes/*", "pipes/"],
                "@services/*": ["services/*", "services/"],
                "@resolvers/*": ["resolvers/*", "resolvers/"],
                "@mock_data/*": ["tests/mock_data/*", "tests/mock_data/"],
                "@environments/*": ["environments/*", "environments/"]
            }
    

    This builds but with 2 big caveats.

    1. Circular dependency errors for any service which imports another service, since the both resolve to @services/index`
    2. All top level imports have to use @services/* instead of just @services/

    I've run tsc -p ./tsconfig.app.json --traceResolution a couple dozen times and grepped for the paths which were throwing errors in the angular build, and all of them are resolving to the right file through tsc.

    I'm not sure why this changed between 6 and 7, since there was no mention of any changes around tsconfig in any of the Changelogs. Anyone else still stuck after following the advice in this thread?

  27. MarcosMeli commented on Nov 16, 2018

    @MarcosMeli

    @seabass223 it works for me with * wilcard with no problems but only if I duplicate paths in tsconfig.json and tsconfig.app.json

    image

    and the imports works fantastic

    image

  28. localyost3000 commented on Nov 16, 2018

    @localyost3000

    Super quick update:

    With the same tsconfig.json I posted above, I was able to get it to build, with no circular dependencies and no stars in the path. I did a global Find and replace for all imports ending in / and replaced them all with /index. This should be default behavior, and tsc resolves without the index, but by adding it, angular compiles fine.

    I'm not super happy with this resolution, but once the Angular team fixes this issue, it should be pretty easy to do another find and replace to remove the /index in every file.

  29. luckylooke commented on Dec 10, 2018

    @luckylooke
  30. gogakoreli commented on Jan 16, 2019

    @gogakoreli

    In my case tsconfig.spec.json was overwriting baseUrl

  31. anilvangari2005 commented on Feb 8, 2019

    @anilvangari2005

    I commented out baseUrl property in tsconfig.app.json and now everything works including intellisense and ng serve.
    Previously intellisense worked but ng serve failed with "Cannot find module" errors.

    tsconfig.json:

    "baseUrl": "./",
    "paths": {
      "@services/*": ["src/app/components/services/*"],
      ...
    }
    

    tsconfig.app.json relevant config

    "compilerOptions": {
      "outDir": "../out-tsc/app",
      //"baseUrl": "./",
      "module": "es2015",
      "types": ["highcharts"]
    },
    
    
  32. anikets43 commented on Feb 24, 2019

    @anikets43

    I have a problem similar to this when I run the tests E2E

    Angular CLI version:

    Angular CLI: 1.7.3
    Node: 8.9.1
    OS: linux x64
    Angular: 5.2.9
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    @angular/cli: 1.7.3
    @angular-devkit/build-optimizer: 0.3.2
    @angular-devkit/core: 0.3.2
    @angular-devkit/schematics: 0.3.2
    @ngtools/json-schema: 1.2.0
    @ngtools/webpack: 1.10.2
    @schematics/angular: 0.3.2
    @schematics/package-update: 0.3.2
    typescript: 2.7.2
    webpack: 3.11.0
    

    tsconfig.json

    {
        "compileOnSave": false,
        "compilerOptions": {
            "outDir": "./dist/out-tsc",
            "sourceMap": true,
            "declaration": false,
            "moduleResolution": "node",
            "emitDecoratorMetadata": true,
            "experimentalDecorators": true,
            "target": "es5",
            "typeRoots": [
                "node_modules/@types"
            ],
            "baseUrl": ".",
            "paths": {
                "@service/*": ["src/app/shared/service/*"],
                "@directive/*": ["src/app/shared/directive/*"],
                "@component/*": ["src/app/shared/component/*"],
                "@entity/*": ["src/app/entity/*"],
                "@enum/*": ["src/app/enum/*"],
                "@environment/*": ["src/environments/*"],
                "@shared/*": ["src/app/shared/*"],
                "@guest/*": ["src/app/guest/*"],
                "@dashboard/*": ["src/app/dashboard/*"],
                "@validator/*": ["src/app/validator/*"],
                "@interface/*": ["src/app/interface/*"],
                "@mask/*": ["src/app/mask/*"],
                "@pipe/*": ["src/app/shared/pipe/*"],
                "@e2e/*": ["e2e/*"],
                "@factory/*": ["factory/*"],
                "@mock/*": ["mock/*"],
                "@database/*": ["database/*"]
            },
            "lib": [
                "es2017",
                "dom"
            ]
        }
    }
    

    tsconfig.e2e.json

    {
        "extends": "../tsconfig.json",
        "compilerOptions": {
            "outDir": "../out-tsc/e2e",
            "module": "commonJS",
            "types": [
                "jasmine",
                "jasminewd2",
                "node"
            ]
        }
    }
    

    Error: Error: Error: Cannot find module '@e2e/utils/utils'

    @ivanguimam Did you find solution for this?

  33. danielpcampagna commented on Feb 27, 2019

    @danielpcampagna

    I am having trouble getting paths to work when building packages. ie in the tsconfig.lib.json
    I have added:

    "paths": {"@lib/*": ["lib/*"], },
    

    to tsconfig.lib.json and then try to utilise it with a path such as

    import { CrossfilterDataComponent } from "@lib/bids/crossfilter-data/crossfilter-data.component";
    

    the target file is src/lib/bids/crossfilter-data/crossfilter-data.component.ts

    @Bengreen I have the same problem. Did you find the solution?

  34. skwny commented on Jul 23, 2019

    @skwny

    Came here b/c I just experienced this same issue. I pieced together a work around from @swimmadude66 solution. For anyone else:

    tsconfig.json compiler options looks like this:

    // tsconfig.json
    "paths": {
      @client/services/*": [
        "src/services/*"
      ]
    }
    

    When importing a service anywhere, I do this:

    // somewhere in the app
    import { Auth_Service } from '@client/services/index';
    

    index.ts is located in the services dir, and contains:

    // index.ts
    export { Auth_Service } from './auth.service';
    export { Loading_Service } from './loading.service';
    export { Store_Service } from './store.service';
    

    There are no more circular dependency warnings after this.

  35. veerabhadraraochikka commented on Jul 31, 2019

    @veerabhadraraochikka

    I commented out baseUrl property in tsconfig.app.json and now everything works including intellisense and ng serve.
    Previously intellisense worked but ng serve failed with "Cannot find module" errors.

    tsconfig.json:

    "baseUrl": "./",
    "paths": {
      "@services/*": ["src/app/components/services/*"],
      ...
    }
    

    tsconfig.app.json relevant config

    "compilerOptions": {
      "outDir": "../out-tsc/app",
      //"baseUrl": "./",
      "module": "es2015",
      "types": ["highcharts"]
    },
    

    while migration from mono app to multi app we should look at baseurl in tsconfig.json

  36. angular-automatic-lock-bot commented on Sep 9, 2019

    @angular-automatic-lock-bot

    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.

  37. locked and limited conversation to collaborators on Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions