Skip to content

inter library dependency inside a workspace: Cannot find module 'library1' #10780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gbharathkumar opened this issue May 10, 2018 · 6 comments
Closed

Comments

@gbharathkumar
Copy link

Versions


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / ? \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.0
Node: 8.11.1
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.6.0
@angular-devkit/core         0.6.0
@angular-devkit/schematics   0.6.0
@schematics/angular          0.6.0
@schematics/update           0.6.0
rxjs                         6.1.0
typescript                   2.7.2


Repro steps

  • create a new angular 6 workspace with an application
  • add two libraries named library1, library2
  • refer library1 in library2 package.
  • compile library1 using ng build --project=library1
  • compile library2 using ng build --project=library2

Observed behavior

* getting exception projects/library2/src/lib/library2.module.ts(3,36): error TS2307: Cannot find module 'library1'.

Desired behavior

Mention any other details that might be useful (optional)

  1. setting the output of library1 to node_modules doesn't work as ng_packagr is not generating the public_api.ts file if the dest path is node_modules.
  2. even adding paths to tsconfig.lib.json doesn't get reflected, neither does the paths in the root tsconfig.json
@wulfsberg
Copy link

Duplicate of #10665?
While it would be nice to have it working out of the box, I got my project working the same way @aitboudad suggests in #10665 (comment), i.e. adding paths to the other library's dist output.

You'd need something like

"paths": {
  "library1": [
	"../../../dist/library1"
  ]
}

in the compilerOptions of library2's tsconfig.lib.json

@clydin
Copy link
Member

clydin commented May 10, 2018

Duplicate of #10665

@clydin clydin marked this as a duplicate of #10665 May 10, 2018
@clydin clydin closed this as completed May 10, 2018
@playground
Copy link

playground commented May 13, 2018

I have the same issue with using npm @scope.

@scope/library1
@scope/library2

ng build @scope/library1
in library2, import {} from '@scope/library1', vscode cannot find it.



@playground
Copy link

It's working now after npm install @scope/library1 in project library1.

@wulfsberg
Copy link

Likely due to ng-packagr/ng-packagr#862, which obsoletes the workaround with paths in tsconfig.lib.json.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants