Angular - custom lib cannot read property 'Directive' of undefined












0














I'm creating a custom Angular 7 library, with some directives, pipes and providers common in all projects of the company; however, I'm facing this strange problem when using the module I created, in another project:



h2r-shared-base.js?9483:1023 Uncaught TypeError: Cannot read property 'Directive' of undefined
at eval (h2r-shared-base.js?9483:1023)
at eval (h2r-shared-base.js?9483:1047)
at createCommonjsModule (h2r-shared-base.js?9483:18)
at eval (h2r-shared-base.js?9483:724)
at Object../node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js (main.bundle.js:955)
at __webpack_require__ (main.bundle.js:712)
at fn (main.bundle.js:95)
at eval (user.service.ts?cada:7)
at Object../src/main/webapp/app/shared/user/user.service.ts (main.bundle.js:11328)
at __webpack_require__ (main.bundle.js:712)
(anonymous) @ h2r-shared-base.js?9483:1023
(anonymous) @ h2r-shared-base.js?9483:1047
createCommonjsModule @ h2r-shared-base.js?9483:18
(anonymous) @ h2r-shared-base.js?9483:724
./node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js @ main.bundle.js:955
__webpack_require__ @ main.bundle.js:712
fn @ main.bundle.js:95
(anonymous) @ user.service.ts?cada:7
./src/main/webapp/app/shared/user/user.service.ts @ main.bundle.js:11328
__webpack_require__ @ main.bundle.js:712
fn @ main.bundle.js:95
(anonymous) @ index.ts?0ab5:7
./src/main/webapp/app/shared/index.ts @ main.bundle.js:11184
__webpack_require__ @ main.bundle.js:712
fn @ main.bundle.js:95
(anonymous) @ app.module.ts?c5f8:6
./src/main/webapp/app/app.module.ts @ main.bundle.js:9102
__webpack_require__ @ main.bundle.js:712
fn @ main.bundle.js:95
(anonymous) @ app.main.ts?38fd:3
./src/main/webapp/app/app.main.ts @ main.bundle.js:9090
__webpack_require__ @ main.bundle.js:712
fn @ main.bundle.js:95
2 @ main.bundle.js:11398
__webpack_require__ @ main.bundle.js:712
(anonymous) @ main.bundle.js:764
(anonymous) @ main.bundle.js:767

./node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js
1023:16-20 "export 'default' (imported as 'core') was not found in '@angular/core'


here is angular.json of the lib project:



{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"shared-base": {
"root": "projects/shared-base",
"sourceRoot": "projects/shared-base/src",
"projectType": "library",
"prefix": "h2r",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/shared-base/tsconfig.lib.json",
"project": "projects/shared-base/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/shared-base/test/test.ts",
"tsConfig": "projects/shared-base/test/tsconfig.spec.json",
"karmaConfig": "projects/shared-base/test/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/shared-base/tsconfig.lib.json",
"projects/shared-base/test/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "shared-modules"
}


I don't know why, it appears that it can't find @angular/core. Could someone explain me what could be causing this problem?










share|improve this question





























    0














    I'm creating a custom Angular 7 library, with some directives, pipes and providers common in all projects of the company; however, I'm facing this strange problem when using the module I created, in another project:



    h2r-shared-base.js?9483:1023 Uncaught TypeError: Cannot read property 'Directive' of undefined
    at eval (h2r-shared-base.js?9483:1023)
    at eval (h2r-shared-base.js?9483:1047)
    at createCommonjsModule (h2r-shared-base.js?9483:18)
    at eval (h2r-shared-base.js?9483:724)
    at Object../node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js (main.bundle.js:955)
    at __webpack_require__ (main.bundle.js:712)
    at fn (main.bundle.js:95)
    at eval (user.service.ts?cada:7)
    at Object../src/main/webapp/app/shared/user/user.service.ts (main.bundle.js:11328)
    at __webpack_require__ (main.bundle.js:712)
    (anonymous) @ h2r-shared-base.js?9483:1023
    (anonymous) @ h2r-shared-base.js?9483:1047
    createCommonjsModule @ h2r-shared-base.js?9483:18
    (anonymous) @ h2r-shared-base.js?9483:724
    ./node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js @ main.bundle.js:955
    __webpack_require__ @ main.bundle.js:712
    fn @ main.bundle.js:95
    (anonymous) @ user.service.ts?cada:7
    ./src/main/webapp/app/shared/user/user.service.ts @ main.bundle.js:11328
    __webpack_require__ @ main.bundle.js:712
    fn @ main.bundle.js:95
    (anonymous) @ index.ts?0ab5:7
    ./src/main/webapp/app/shared/index.ts @ main.bundle.js:11184
    __webpack_require__ @ main.bundle.js:712
    fn @ main.bundle.js:95
    (anonymous) @ app.module.ts?c5f8:6
    ./src/main/webapp/app/app.module.ts @ main.bundle.js:9102
    __webpack_require__ @ main.bundle.js:712
    fn @ main.bundle.js:95
    (anonymous) @ app.main.ts?38fd:3
    ./src/main/webapp/app/app.main.ts @ main.bundle.js:9090
    __webpack_require__ @ main.bundle.js:712
    fn @ main.bundle.js:95
    2 @ main.bundle.js:11398
    __webpack_require__ @ main.bundle.js:712
    (anonymous) @ main.bundle.js:764
    (anonymous) @ main.bundle.js:767

    ./node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js
    1023:16-20 "export 'default' (imported as 'core') was not found in '@angular/core'


    here is angular.json of the lib project:



    {
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
    "shared-base": {
    "root": "projects/shared-base",
    "sourceRoot": "projects/shared-base/src",
    "projectType": "library",
    "prefix": "h2r",
    "architect": {
    "build": {
    "builder": "@angular-devkit/build-ng-packagr:build",
    "options": {
    "tsConfig": "projects/shared-base/tsconfig.lib.json",
    "project": "projects/shared-base/ng-package.json"
    }
    },
    "test": {
    "builder": "@angular-devkit/build-angular:karma",
    "options": {
    "main": "projects/shared-base/test/test.ts",
    "tsConfig": "projects/shared-base/test/tsconfig.spec.json",
    "karmaConfig": "projects/shared-base/test/karma.conf.js"
    }
    },
    "lint": {
    "builder": "@angular-devkit/build-angular:tslint",
    "options": {
    "tsConfig": [
    "projects/shared-base/tsconfig.lib.json",
    "projects/shared-base/test/tsconfig.spec.json"
    ],
    "exclude": [
    "**/node_modules/**"
    ]
    }
    }
    }
    }
    },
    "defaultProject": "shared-modules"
    }


    I don't know why, it appears that it can't find @angular/core. Could someone explain me what could be causing this problem?










    share|improve this question



























      0












      0








      0







      I'm creating a custom Angular 7 library, with some directives, pipes and providers common in all projects of the company; however, I'm facing this strange problem when using the module I created, in another project:



      h2r-shared-base.js?9483:1023 Uncaught TypeError: Cannot read property 'Directive' of undefined
      at eval (h2r-shared-base.js?9483:1023)
      at eval (h2r-shared-base.js?9483:1047)
      at createCommonjsModule (h2r-shared-base.js?9483:18)
      at eval (h2r-shared-base.js?9483:724)
      at Object../node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js (main.bundle.js:955)
      at __webpack_require__ (main.bundle.js:712)
      at fn (main.bundle.js:95)
      at eval (user.service.ts?cada:7)
      at Object../src/main/webapp/app/shared/user/user.service.ts (main.bundle.js:11328)
      at __webpack_require__ (main.bundle.js:712)
      (anonymous) @ h2r-shared-base.js?9483:1023
      (anonymous) @ h2r-shared-base.js?9483:1047
      createCommonjsModule @ h2r-shared-base.js?9483:18
      (anonymous) @ h2r-shared-base.js?9483:724
      ./node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js @ main.bundle.js:955
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      (anonymous) @ user.service.ts?cada:7
      ./src/main/webapp/app/shared/user/user.service.ts @ main.bundle.js:11328
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      (anonymous) @ index.ts?0ab5:7
      ./src/main/webapp/app/shared/index.ts @ main.bundle.js:11184
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      (anonymous) @ app.module.ts?c5f8:6
      ./src/main/webapp/app/app.module.ts @ main.bundle.js:9102
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      (anonymous) @ app.main.ts?38fd:3
      ./src/main/webapp/app/app.main.ts @ main.bundle.js:9090
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      2 @ main.bundle.js:11398
      __webpack_require__ @ main.bundle.js:712
      (anonymous) @ main.bundle.js:764
      (anonymous) @ main.bundle.js:767

      ./node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js
      1023:16-20 "export 'default' (imported as 'core') was not found in '@angular/core'


      here is angular.json of the lib project:



      {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "version": 1,
      "newProjectRoot": "projects",
      "projects": {
      "shared-base": {
      "root": "projects/shared-base",
      "sourceRoot": "projects/shared-base/src",
      "projectType": "library",
      "prefix": "h2r",
      "architect": {
      "build": {
      "builder": "@angular-devkit/build-ng-packagr:build",
      "options": {
      "tsConfig": "projects/shared-base/tsconfig.lib.json",
      "project": "projects/shared-base/ng-package.json"
      }
      },
      "test": {
      "builder": "@angular-devkit/build-angular:karma",
      "options": {
      "main": "projects/shared-base/test/test.ts",
      "tsConfig": "projects/shared-base/test/tsconfig.spec.json",
      "karmaConfig": "projects/shared-base/test/karma.conf.js"
      }
      },
      "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
      "tsConfig": [
      "projects/shared-base/tsconfig.lib.json",
      "projects/shared-base/test/tsconfig.spec.json"
      ],
      "exclude": [
      "**/node_modules/**"
      ]
      }
      }
      }
      }
      },
      "defaultProject": "shared-modules"
      }


      I don't know why, it appears that it can't find @angular/core. Could someone explain me what could be causing this problem?










      share|improve this question















      I'm creating a custom Angular 7 library, with some directives, pipes and providers common in all projects of the company; however, I'm facing this strange problem when using the module I created, in another project:



      h2r-shared-base.js?9483:1023 Uncaught TypeError: Cannot read property 'Directive' of undefined
      at eval (h2r-shared-base.js?9483:1023)
      at eval (h2r-shared-base.js?9483:1047)
      at createCommonjsModule (h2r-shared-base.js?9483:18)
      at eval (h2r-shared-base.js?9483:724)
      at Object../node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js (main.bundle.js:955)
      at __webpack_require__ (main.bundle.js:712)
      at fn (main.bundle.js:95)
      at eval (user.service.ts?cada:7)
      at Object../src/main/webapp/app/shared/user/user.service.ts (main.bundle.js:11328)
      at __webpack_require__ (main.bundle.js:712)
      (anonymous) @ h2r-shared-base.js?9483:1023
      (anonymous) @ h2r-shared-base.js?9483:1047
      createCommonjsModule @ h2r-shared-base.js?9483:18
      (anonymous) @ h2r-shared-base.js?9483:724
      ./node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js @ main.bundle.js:955
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      (anonymous) @ user.service.ts?cada:7
      ./src/main/webapp/app/shared/user/user.service.ts @ main.bundle.js:11328
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      (anonymous) @ index.ts?0ab5:7
      ./src/main/webapp/app/shared/index.ts @ main.bundle.js:11184
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      (anonymous) @ app.module.ts?c5f8:6
      ./src/main/webapp/app/app.module.ts @ main.bundle.js:9102
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      (anonymous) @ app.main.ts?38fd:3
      ./src/main/webapp/app/app.main.ts @ main.bundle.js:9090
      __webpack_require__ @ main.bundle.js:712
      fn @ main.bundle.js:95
      2 @ main.bundle.js:11398
      __webpack_require__ @ main.bundle.js:712
      (anonymous) @ main.bundle.js:764
      (anonymous) @ main.bundle.js:767

      ./node_modules/@h2r/shared-base/fesm5/h2r-shared-base.js
      1023:16-20 "export 'default' (imported as 'core') was not found in '@angular/core'


      here is angular.json of the lib project:



      {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "version": 1,
      "newProjectRoot": "projects",
      "projects": {
      "shared-base": {
      "root": "projects/shared-base",
      "sourceRoot": "projects/shared-base/src",
      "projectType": "library",
      "prefix": "h2r",
      "architect": {
      "build": {
      "builder": "@angular-devkit/build-ng-packagr:build",
      "options": {
      "tsConfig": "projects/shared-base/tsconfig.lib.json",
      "project": "projects/shared-base/ng-package.json"
      }
      },
      "test": {
      "builder": "@angular-devkit/build-angular:karma",
      "options": {
      "main": "projects/shared-base/test/test.ts",
      "tsConfig": "projects/shared-base/test/tsconfig.spec.json",
      "karmaConfig": "projects/shared-base/test/karma.conf.js"
      }
      },
      "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
      "tsConfig": [
      "projects/shared-base/tsconfig.lib.json",
      "projects/shared-base/test/tsconfig.spec.json"
      ],
      "exclude": [
      "**/node_modules/**"
      ]
      }
      }
      }
      }
      },
      "defaultProject": "shared-modules"
      }


      I don't know why, it appears that it can't find @angular/core. Could someone explain me what could be causing this problem?







      angular angular-cli rollupjs angular-module angular-library






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 '18 at 15:34







      brevleq

















      asked Nov 20 '18 at 15:17









      brevleqbrevleq

      30153479




      30153479
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396101%2fangular-custom-lib-cannot-read-property-directive-of-undefined%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396101%2fangular-custom-lib-cannot-read-property-directive-of-undefined%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy