-1

It's my first post on stackoverflow.

I'm trying to import a library developed by my society in an angular-cli project.

This is an angular-cli project (Angular v6) and the library is an Angular project build with webpack.

When I import the lib, I get a lot a errors.

My process :

  1. import the library in the package.json
  2. import some script (relative to my specific lib) in my angular.json file

lib files

"scripts": [
    "node_modules/chart.js/dist/Chart.js",
    "node_modules/hammerjs/hammer.min.js",
    "node_modules/email-builder/dist/polyfills.bundle.007e569078d25408929d.js",
    "node_modules/email-builder/dist/main.bundle.007e569078d25408929d.js"
]

When I compile my project, I receive this error : error

I tried to call lib methods like this :

_init() {
    window['angularComponentRef'].zone.run(() => {
        window['angularComponentRef'].component.initEmailBuilder();
    });
}
  • 1
    Please consider using actual text (with code formatting) instead of images, as long as the images only contain text. – Roi Danton Sep 25 '18 at 15:16

1 Answers1

2

Have you run npm install after the lib is added to package.json? You can delete node_modules folder before to have a new instalation.

It looks like the lib is missing or some wrong version is referenced at runtime.

In the webpack case - angular-cli has webpack installed as dependency. You should not add a new one. Angular-cli works only with a specific webpack version.

Tihomir
  • 124
  • 1
  • 11