mzuccaroli / angular-google-tag-manager

A service library for integrate google tag manager in your angular project
https://itnext.io/how-to-add-google-tag-manager-to-an-angular-application-fc68624386e2
MIT License
136 stars 78 forks source link

Library throws error when building the code #106

Closed ShreyanshGitShukla closed 2 years ago

ShreyanshGitShukla commented 2 years ago

Package Dependencies:

"dependencies": { "@angular/animations": "~9.0.3", "@angular/cdk": "^9.2.4", "@angular/common": "~9.0.3", "@angular/compiler": "~9.0.3", "@angular/core": "~9.0.3", "@angular/forms": "~9.0.3", "@angular/material": "^9.2.4", "@angular/platform-browser": "~9.0.3", "@angular/platform-browser-dynamic": "~9.0.3", "@angular/router": "~9.0.3", "@azure/msal-angular": "^2.0.2", "@azure/msal-browser": "^2.15.0", "@ngx-formly/core": "^5.10.22", "@ngx-formly/material": "^5.10.22", "angular-google-tag-manager": "^1.4.4", "angular-mydatepicker": "^0.11.4", "angular-ng-stepper": "^1.0.6", "bn-ng-idle": "^1.0.1", "chart.js": "^2.9.3", "chartjs-plugin-datalabels": "^1.0.0", "core-js": "^3.16.1", "karma-sonarqube-unit-reporter": "0.0.23", "net": "^1.0.2", "ng2-charts": "^2.2.3", "rxjs": "^6.5.5", "rxjs-compat": "^6.6.7", "tslib": "^1.10.0", "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/build-angular": "~0.900.4", "@angular/cli": "~9.0.4", "@angular/compiler-cli": "~9.0.3", "@angular/language-service": "~9.0.3", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", "codelyzer": "^5.1.2", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.3.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~2.1.0", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.2", "prettier": "^2.3.0", "protractor": "~5.4.3", "stickyfilljs": "^2.1.0", "ts-node": "~8.3.0", "tslint": "~5.18.0", "tslint-config-prettier": "^1.18.0", "typescript": "~3.7.5", "webpack-bundle-analyzer": "^4.4.2" }

Error : image image image

mzuccaroli commented 2 years ago

you are using a old version of angular (9 according to your package) this version is released to support angular 13 i think the best solution for compatibility is install old version of the library (1.3.x should work)

ShreyanshGitShukla commented 2 years ago

@mzuccaroli I will try this out for sure. The thing that I am confused about is, how was it working for V1.4.2 since last 30-40 days. This issue popped up since today morning.

PS: I haven't verified that on the last weekend though.

mzuccaroli commented 2 years ago

during the weekend I released the new angular 13 packages, that has different requirements (such as node 14) i thnk this is the breaking change (actually a 1.5.x version could have been more appropriate because of breaking changes) another user with an old version of angular had a similar issue https://github.com/mzuccaroli/angular-google-tag-manager/issues/105 and i thin you ca safely use his solution untill you update your angular version: "dependencies": { ... "angular-google-tag-manager": "=1.4.2", ... }

Shyam7675 commented 2 years ago

Facing same issue can you help me to solve this issue as I am using angular 11

mzuccaroli commented 2 years ago

@Shyam7675 the best version for angular 11 is 1.3.x so npm install angular-google-tag-manager@1.3.2 or in your package.json "dependencies": { ... "angular-google-tag-manager": "=1.3.2", ... }

the 1.4.x is released only for angular 12/13 support it does not add features so you can safely use 1.3.x

emartinrda commented 2 years ago

OTHER SOLUTION: Had the same issue, as you can see my the screenshot there are two methods for implementing in the modules.ts

If you use the first one (adding in providers) and also add line "import { GoogleTagManagerModule } from 'angular-google-tag-manager';" you will have issues in 1.4.2 or above.

If you only use "providers" you will have no issues..

photo_2022-05-23_14-46-30