Skip to content

Module not found: Error: Can't resolve ' commonjs-proxy:../.. #944

@yorkie-m

Description

@yorkie-m

Type 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

  1. 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"
            }
          }
        },
  1. Install the library into another angular 6 application and attempt to consume a component from the installed library

  2. 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

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