Multi-library which depends on each other build error: Cannot find module
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Description
I create a repo which has two libraries, one of them depends on the other. When I build that library I get this error: Cannot find module xx.
How To Reproduce
You can reproduce it with the repo here. It will be ok if you build lib-a by run ng build lib-a
, but get error if you build lib-b which import lib-a in lib-b/src/lib/lib-b.module.ts
. I have set the path-mapping in lib-b/tsconfig.lib.json
like below.
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": ["dom", "es2018"],
"baseUrl": "./",
"paths": {
"lib-a": ["../lib-a"]
}
},
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableResourceInlining": true
},
"exclude": ["src/test.ts", "**/*.spec.ts"]
}
Here is the error message when I run ng build lib-b
ERROR: projects/lib-b/src/lib/lib-b.module.ts(3,28): error TS2307: Cannot find module 'lib-a'.
projects/lib-b/src/lib/lib-b.module.ts(7,13): Error during template compile of 'LibBModule'
Could not resolve lib-a relative to [object Object]..
projects/lib-b/src/lib/lib-b.module.ts(7,13): Error during template compile of 'LibBModule'
Could not resolve lib-a relative to [object Object]..
An unhandled exception occurred: projects/lib-b/src/lib/lib-b.module.ts(3,28): error TS2307: Cannot find module 'lib-a'.
projects/lib-b/src/lib/lib-b.module.ts(7,13): Error during template compile of 'LibBModule'
Could not resolve lib-a relative to [object Object]..
projects/lib-b/src/lib/lib-b.module.ts(7,13): Error during template compile of 'LibBModule'
Could not resolve lib-a relative to [object Object]..
Expected Behaviour
Build multi-library which depends on each other successfully.
Version Information
$ node_modules/.bin/ng-packagr --version
ng-packagr: 5.1.0
@angular/*: 8.1.1
typescript: 3.4.3
rxjs: 6.4.0
node: 10.15.3
npm: 6.4.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Problem in a multiple library repo: can't inter-depend on each ...
If I create a repo made of two libraries for which one depends on the other ... -ng-date-utils/ts/src/module.ts:4:23: Cannot find module '.
Read more >How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >Xcode Previews doesn't work when u… - Apple Developer
I keep getting a Xcode Previews error in Xcode 12 from a package that imports other packages. As soon as I remove the...
Read more >Libtool - GNU.org
When building packages with static libraries, the libraries may depend circularly on each other (shared libs can too, but for those it doesn't...
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
In my case, I need to install the react-icons package so the freeCodeCamp icon can be resolved. I'll do that by running yarn...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PS: you also need to add
"lib-a/*": ["../../dist/lib-a/*"]
to your pathsThis issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. This action has been performed automatically by a bot.