Module not found: Error: Can't resolve ' commonjs-proxy:../..
See original GitHub issueType of Issue
[x ] Bug Report
[ ] Feature Request
Description
Unsure if this is an angular-cli issue or ng-packagr.
Have an angular 6 application containing a library project. When I build using ng-packagr directly the resulting npm package can be consumed from another Angular 6 application. When I build using the angular-cli the resulting package cannot be consumed from another Angular 6 application and get multiple errors as follows when trying to build the consuming Angular 6 app:
ERROR in ./node_modules/c-lib/fesm5/c-lib.js Module not found: Error: Can’t resolve ’ commonjs-proxy:…/…/a-service/a.service’ in ‘C:\data\sandbox\angular\example-ng6-lib-app\node_modules\c-lib\fesm5’
How To Reproduce
- Given the following configuration in angular.json, build the library using the angular cli and then package using npm:
ng build --prod c-lib
cd dist/c-lib && npm pack
angular.json:
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/c-lib/tsconfig.lib.json",
"project": "projects/c-lib/ng-package.json"
},
"configurations": {
"production": {
"project": "projects/c-lib/ng-package.prod.json"
}
}
},
-
Install the library into another angular 6 application and attempt to consume a component from the installed library
-
Build the consuming application
Expected Behaviour
Expect the consuming application to build successfully and consumed component to function correctly.
This expected behaviour is achieved when using ng-packagr directly replacing step 1 above with the following:
ng-packagr -p ./projects/c-lib/ng-package.prod.json
cd dist/c-lib && npm pack
Version Information
$ node_modules/.bin/ng-packagr --version
ng-packagr: 4.0.0-rc.0
@angular/compiler: 6.0.0
rollup: 0.59.4
tsickle: 0.27.5
typescript: 2.7.2
Please include all version numbers that might be relevant, e.g. third-party libraries
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:17 (5 by maintainers)
Top GitHub Comments
@AlexanderKozhevin, for thanks the reproduction. And as always in the open source community a good reproduction always gets things solved fast.
What I noticed is that the module format used in
esm5
andfesm5
iscommonjs
. This is due that intsconfig.lib.json
you don’t have a module specified. Please add the following.@alan-agius4 https://github.com/AlexanderKozhevin/angular6-library-test Here we are. Created project from scratch, added library, got an error. Please, let me know if you know how to fix that.