Cannot add task 'processDebugGoogleServices' as a task with that name already exists - ionic4

What went wrong?
org.gradle.api.internal.tasks.DefaultTaskContainer$DuplicateTaskException:
Cannot add task 'processDebugGoogleServices' as a task with that name
already exists.
I want to test firebase FCM plugin, but it seems to have a lot of errors,
after solved many of them, here what I'm trying to do: ionic cordova build
android, I have this error:
ionic info:
platforms\android\cordova-plugin-fcm-with-dependecy-updated:
buildscript {
repositories {
mavenCentral()
jcenter()
mavenLocal()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.+'
classpath 'com.google.gms:google-services:3.1.+'
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile 'com.google.firebase:firebase-core:10.+'
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin
from non-root gradle file
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
platforms\android\cordova-support-google-services
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply
plugin from non-root gradle file
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

What works for me was changing the line:
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
in platforms\android\cordova-plugin-fcm-with-dependecy-updated
to this:
ext.postBuildExtras = {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}

I've had several issues with the plugin as well including the one you mention above. My problem was that my platforms/android/src/build.gradle, for some unknown reason, had duplicate dependencies (com.google.firebase:firebase-messaging & com.google.firebase:firebase-core) after removing the duplicates everything worked fine. Hope this helps!

I removed {phonegap-plugin-push": "2.2.3",} from my package.json.
my "package.json" was ..
{
"name": "TaxMan_v2",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/common": "^7.2.2",
"#angular/core": "^7.2.2",
"#angular/forms": "^7.2.2",
"#angular/http": "^7.2.2",
"#angular/platform-browser": "^7.2.2",
"#angular/platform-browser-dynamic": "^7.2.2",
"#angular/router": "^7.2.2",
"#ionic-native/core": "^5.0.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^4.0.0",
"#ionic/storage": "^2.2.0",
"chart.js": "^2.7.3",
"cordova-android": "7.1.4",
"cordova-plugin-device": "2.0.2",
"cordova-plugin-fcm-with-dependecy-updated": "2.4.0",
"cordova-plugin-ionic-keyboard": "^2.0.5",
"cordova-plugin-ionic-webview": "^3.0.0",
"cordova-plugin-ms-azure-mobile-apps": "^2.0.2",
"cordova-plugin-splashscreen": "5.0.2",
"cordova-plugin-statusbar": "2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"cordova-support-google-services": "1.1.0",
"core-js": "^2.5.4",
"phonegap-plugin-multidex": "1.0.0",
"phonegap-plugin-push": "2.2.3",
"rxjs": "~6.3.3",
"zone.js": "~0.8.29"
},
"devDependencies": {
"#angular-devkit/architect": "~0.12.3",
"#angular-devkit/build-angular": "~0.12.3",
"#angular-devkit/core": "~7.2.3",
"#angular-devkit/schematics": "~7.2.3",
"#angular/cli": "~7.2.3",
"#angular/compiler": "~7.2.2",
"#angular/compiler-cli": "~7.2.2",
"#angular/language-service": "~7.2.2",
"#ionic/angular-toolkit": "~1.2.0",
"#types/node": "~10.12.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.4",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.0.0",
"tslint": "~5.12.0",
"typescript": "~3.1.6"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {},
"cordova-plugin-fcm-with-dependecy-updated": {}
},
"platforms": [
"android"
]
}
}

Related

quasar failed on RUN quasar build

I want to build quasar project with command quasar build. The compile progress goes to 100% but I get the error after build:
App · ⚠️ 1 error encountered:
./node_modules/htmlparser2/lib/esm/index.js 59:9
Module parse failed: Unexpected token (59:9)
File was processed with these loaders:
* ./node_modules/#quasar/app/lib/webpack/loader.transform-quasar-imports.js
You may need an additional loader to handle the result of these loaders.
| return getFeed(parseDOM(feed, options));
| }
> export * as DomUtils from "domutils";
| // Old name for DomHandler
| export { DomHandler as DefaultHandler };
# ./node_modules/sanitize-html/index.js 1:19-41
# ./node_modules/vue-sanitize/dist/vue-sanitize.js
# ./src/boot/sanitize.ts
# ./.quasar/client-entry.js
# multi ./.quasar/client-entry.js
App · ⚠️ [FAIL] Build failed with 1 error. Check log above.
This is my package.json:
{
"name": "rfasdef",
"version": "0.0.1",
"description": "",
"productName": "",
"cordovaId": "",
"capacitorId": "",
"author": "",
"private": true,
"scripts": {
"lint": "eslint --ext .js,.ts,.vue --ignore-path .gitignore ./"
},
"dependencies": {
"#quasar/extras": "^1.0.0",
"#types/file-saver": "^2.0.5",
"#types/jwt-decode": "^3.1.0",
"axios": "^0.18.1",
"crypto-js": "^4.0.0",
"echarts": "^4.6.0",
"file-saver": "^2.0.5",
"formik": "^2.2.9",
"jalaali-js": "^1.2.3",
"jwt-decode": "^3.1.2",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"moment-duration-format": "^2.3.2",
"moment-jalaali": "^0.9.6",
"num2persian": "^3.2.2",
"persianjs": "^0.4.0",
"qjdatetime": "^1.1.0",
"quasar": "^1.9.5",
"sass": "^1.45.0",
"vue-echarts": "^5.0.0-beta.0",
"vue-i18n": "^8.0.0",
"vue-persian-datetime-picker": "^2.10.1",
"vue-sanitize": "^0.2.0"
},
"devDependencies": {
"#quasar/app": "^1.6.2",
"#quasar/quasar-app-extension-dotenv": "^1.0.1",
"#types/lodash": "^4.14.150",
"#types/moment-jalaali": "^0.7.5",
"#types/node": "^10.17.15",
"#typescript-eslint/eslint-plugin": "^2.17.0",
"#typescript-eslint/parser": "^2.17.0",
"babel-eslint": "^10.0.1",
"eslint": "^6.8.0",
"eslint-config-standard": "^14.1.0",
"eslint-loader": "^3.0.3",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.1.2",
"vue-property-decorator": "^8.3.0",
"vuex-class": "^0.3.2",
"vuex-module-decorators": "^0.11.0"
},
"engines": {
"node": ">= 10.18.1",
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
},
"browserslist": [
"last 1 version, not dead, ie >= 11"
],
"resolutions": {
"#babel/parser": "7.7.5"
}
}
It was working yesterday but today it's not working!
I tried installing packages with both yarn and npm. But its not working.
Try this:
Deleting package-lock.json and folder node_modules
then run npm install or yarn install
then run quasar build

Cannot find module from setup-jest.js

I have an Angular library that I'm working to update from Angular 11 to 13. Jest ran fine in 11 and 12, but now I'm having a lot of trouble with v13. I've followed the steps outlined here
The error I'm getting is as follows:
Cannot find module '#angular/core/testing' from 'node_modules/jest-preset-angular/setup-jest.js'
Require stack:
node_modules/jest-preset-angular/setup-jest.js
jest.setup.ts
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
at Object.<anonymous> (node_modules/jest-preset-angular/setup-jest.js:2:24)
It seems odd that it's looking for angular core files within the setup-jest file.
jest.config.js
module.exports = {
preset: 'jest-preset-angular',
moduleFileExtensions: ['ts', 'html', 'js', 'json', 'mjs'],
snapshotSerializers: [
],
roots: ['src'],
moduleNameMapper: {
'^lodash-es$': '<rootDir>/node_modules/lodash/index.js'
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
testMatch: ['<rootDir>/src/**/*.spec.ts'],
transform: {
'^.+\\.ts?$': 'ts-jest',
'^.+\\.mjs?$': 'ts-jest',
},
transformIgnorePatterns: ['node_modules/(?!(jest-test))', 'node_modules/(?!.*\\.mjs$)', 'node_modules/(?!\\#angular)'],
coveragePathIgnorePatterns: ['<rootDir>/node_modules/'],
coverageReporters: ['json', 'text', 'html', 'cobertura'],
reporters: ['default', ['jest-junit', { outputDirectory: 'TestResults', outputName: 'jest-junit.xml' }]],
};
jest.setup.ts
import 'zone.js';
import 'zone.js/testing';
import 'jest-preset-angular/setup-jest';
package.json
{
"name": "my-lib-name",
"version": "12.0.2",
"description": "",
"main": "src/main.ts",
"scripts": {
"build": "npm run clean && npm run build:types && npm run build:umd && npm run build:esm2015 && npm run build:app",
"build:app": "tsc --project tsconfig.app.json",
"build:types": "tsc --project tsconfig.app.json --emitDeclarationOnly",
"build:umd": "tsc --project tsconfig.umd.json",
"build:esm2015": "tsc --project tsconfig.esm2015.json",
"clean": "rimraf dist",
"test": "jest --watch-all --detect-open-handles --reporters=default",
"lint": "eslint -c .eslintrc.js --ext .ts ./src",
"ci:test": "jest --ci --no-cache --maxWorkers=4 --detect-open-handles --coverage",
"postbuild": "node scripts/postbuild.js"
},
"author": "",
"license": "ISC",
"peerDependencies": {
"#types/lodash-es": "^4.17.4",
"date-fns": "^2.13.0",
"lodash-es": "^4.17.21",
"rxjs": "^6.5.5"
},
"devDependencies": {
"#angular-devkit/build-angular": "^13.3.9",
"#angular/animations": "^13.3.11",
"#angular/cdk": "^12.2.13",
"#angular/cli": "^13.3.9",
"#angular/common": "^13.3.11",
"#angular/compiler": "^13.3.11",
"#angular/compiler-cli": "^13.3.11",
"#angular/core": "^13.3.11",
"#angular/forms": "^13.3.11",
"#angular/material": "^12.2.13",
"#angular/platform-browser": "^13.3.11",
"#angular/platform-browser-dynamic": "^13.3.11",
"#types/chance": "^1.1.3",
"#types/estree": "^1.0.0",
"#types/jest": "^26.0.22",
"#types/lodash": "^4.14.168",
"#types/lodash-es": "^4.17.4",
"#typescript-eslint/eslint-plugin": "^4.14.2",
"#typescript-eslint/parser": "^4.14.2",
"chance": "^1.1.8",
"date-fns": "^2.13.0",
"eslint": "^7.19.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsdoc": "^31.6.0",
"eslint-plugin-prefer-arrow": "^1.2.3",
"jest": "^26.6.3",
"jest-junit": "^12.0.0",
"jest-marbles": "^2.5.1",
"jest-preset-angular": "^12.2.0",
"lodash-es": "^4.17.21",
"rxjs": "6.5.5",
"ts-jest": "^26.5.4",
"ts-loader": "^8.0.17",
"ts-node": "^9.1.1",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
"zone.js": "~0.11.4"
},
"dependencies": {
"ng-packagr": "^12.2.7"
}
}
It seems that you are on an old version of Jest (version 26). Jest Preset Angular version 12 requires Jest version 28.
According to Jest Preset Angular's documentation, you are missing this setting in jest.config.js:
module.exports = {
globalSetup: 'jest-preset-angular/global-setup',
}
Make sure to review Jest Preset Angular's migration guide for Angular 13.

Error when activate Ivy compiler on Angular 10 error NG6003-could not resolve to a NgModule

We recently migrated our app to Angular 10 and PrimeNG 9, and now we are preparing to migrate these frameworks to the latest version.
We trying to prepare our app to migration and want to use Ivy Compiler as Angular recommends.
But when activate Ivy compiler and aot to true it shows the following error when do ng build:
ERROR in
node_modules/#maestro-ng/primeng/maestro-primeng.module.d.ts:1:22 -
error NG6003: Appears in the NgModule.exports of AppSharedModule, but
could not be resolved to an NgModule, Component, Directive, or Pipe
class.
This likely means that the library (#maestro-ng/primeng) which
declares MaestroPrimengModule has not been processed correctly by
ngcc, or is not compatible with Angular Ivy. Check if a newer version
of the library is available, and update if so. Also consider checking
with the library's authors to see if the library is expected to be
compatible with Ivy.
This is the complete package.json:
{
"name": "codex-frontend",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"dev": "ng serve -c dev --watch=false",
"postinstall": "ngcc",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^10.2.5",
"#angular/cdk": "^10.2.7",
"#angular/common": "^10.2.5",
"#angular/compiler": "^10.2.5",
"#angular/core": "^10.2.5",
"#angular/forms": "^10.2.5",
"#angular/platform-browser": "^10.2.5",
"#angular/platform-browser-dynamic": "^10.2.5",
"#angular/router": "^10.2.5",
"#fortawesome/fontawesome-free": "5.15.4",
"#fullcalendar/core": "5.9.0",
"#maestro-ng/core": "https://nexus.myorg.com.br/repository/npm-all/#maestro-ng/core/-/core-1.10.0.tgz",
"#maestro-ng/primeng": "https://nexus.myorg.com.br/repository/npm-all/#maestro-ng/primeng/-/primeng-1.10.0.tgz",
"#types/pdfjs-dist": "2.7.5",
"bootstrap": "5.1.1",
"chart.js": "3.5.1",
"core-js": "3.18.0",
"g": "2.0.1",
"jquery": "3.6.0",
"js-base64": "3.7.2",
"moment": "2.29.1",
"ng2-currency-mask": "9.0.2",
"ng2-pdfjs-viewer": "6.0.2",
"ngx-moment": "5.0.0",
"pdfjs-dist": "2.9.359",
"#popperjs/core": "2.10.1",
"primeflex": "2.0.0",
"primeicons": "4.0.0",
"primeng": "9.1.3",
"quill": "1.3.7",
"rxjs": "6.6.2",
"simple-pdf-viewer": "2.0.3",
"tslib": "2.3.1",
"zone.js": "^0.10.3"
},
"devDependencies": {
"#angular-devkit/build-angular": "^0.1000.8",
"#angular/cli": "^10.2.3",
"#angular/compiler-cli": "10.2.5",
"#angular/language-service": "10.2.5",
"#fortawesome/fontawesome-free": "5.8.2",
"#types/jasmine": "3.9.1",
"#types/jasminewd2": "2.0.10",
"#types/node": "16.9.6",
"codelyzer": "6.0.2",
"jasmine-core": "3.9.0",
"jasmine-spec-reporter": "7.0.0",
"karma": "6.3.4",
"karma-chrome-launcher": "3.1.0",
"karma-cli": "2.0.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-jasmine": "4.0.1",
"karma-jasmine-html-reporter": "1.7.0",
"protractor": "7.0.0",
"ts-node": "10.2.1",
"tslint": "^5.20.1",
"tslint-eslint-rules": "^5.4.0",
"typescript": "3.9.7"
}
}
Even when use `"postinstall": "ngcc" it does not work.
Is it possible to use Ivy With Angular 10 and PrimeNG 9 our we need to first migrate PrimeNG to 10?
PrimeNG does line with the Angular major version.
PrimeNG 10 depends on Angular 10, PrimeNG 11 depends on Angular 11.
You can find the offical source of the information on here
The error is caused by an internal library that is not builded using Ivy.
If you encounter this error because of an internal library of your company, make sure this library is builded using Ivy. As you may know already , ViewEngine is deprecated and will be removed soon.
"postinstall": "ngcc --properties es2015 es5 browser module main --first-only --create-ivy-entry-points"
Check out this conversation. ngcc's source has documentation

Why does package.lock file requirements section change when the related package stays the same?

How is this package-lock.json change possible:
Before:
...
"chokidar": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
"integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=",
"requires": {
"anymatch": "1.3.2",
"async-each": "1.0.3",
"glob-parent": "2.0.0",
"inherits": "2.0.4",
"is-binary-path": "1.0.1",
"is-glob": "2.0.1",
"path-is-absolute": "1.0.1",
"readdirp": "2.2.1"
}
},
...
After:
...
"chokidar": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
"integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=",
"requires": {
"anymatch": "^1.3.0",
"async-each": "^1.0.0",
"fsevents": "^1.0.0",
"glob-parent": "^2.0.0",
"inherits": "^2.0.1",
"is-binary-path": "^1.0.0",
"is-glob": "^2.0.0",
"path-is-absolute": "^1.0.0",
"readdirp": "^2.0.0"
}
},
...
This happens inside a docker container -- so platform is not an issue. integrity field matches -- so WTF. Required versions change (that could be npm audit) but fsevents as a requirement is new while the package has not changed.
Can anybody give me a clue?

npm installing hundreds of packages

npm now installs a package-lock.json every time which seems to be a part of npm now. However, this simple package.json file when run with npm install installs over 300 packages. what could be going wrong and why are there 300+? even without the package-lock file when run (it then creates the lock file) and still gives 300+ packages
{
"name": "Package",
"version": "0.0.1",
"dependencies": {},
"devDependencies": {
"grunt": "^1.0.2",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-compress": "^1.4.3",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^2.2.1",
"grunt-contrib-uglify": "^3.3.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-sass": "^2.1.0",
"grunt-usemin": "^3.1.1"
}
}
Those packages depend on other packages, which depend on other packages, which depend on yet other packages…. A package manager resolves that entire dependency graph, which can easily grow into the hundreds from an innocent-looking initial list.
The package-lock.json file you mention can help you understand how this happens for your particular dependencies. Look for "requires". For example, in your setup, grunt-sass requires node-sass:
"grunt-sass": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/grunt-sass/-/grunt-sass-2.1.0.tgz",
"integrity": "sha512-XkexnQt/9rhReNd+Y7T0n/2g5FqYOQKfi2iSlpwDqvgs7EgEaGTxNhnWzHnbW5oNRvzL9AHopBG3AgRxL0d+DA==",
"dev": true,
"requires": {
"each-async": "1.1.1",
"node-sass": "4.9.0",
"object-assign": "4.1.1"
}
},
…which has 19 separate dependencies:
"node-sass": {
"version": "4.9.0",
...
"requires": {
"async-foreach": "0.1.3",
"chalk": "1.1.3",
"cross-spawn": "3.0.1",
"gaze": "1.1.3",
"get-stdin": "4.0.1",
"glob": "7.0.6",
"in-publish": "2.0.0",
"lodash.assign": "4.2.0",
"lodash.clonedeep": "4.5.0",
"lodash.mergewith": "4.6.1",
"meow": "3.7.0",
"mkdirp": "0.5.1",
"nan": "2.10.0",
"node-gyp": "3.6.2",
"npmlog": "4.1.2",
"request": "2.79.0",
"sass-graph": "2.2.4",
"stdout-stream": "1.4.0",
"true-case-path": "1.0.2"
},
...
}
…and just one of those, request, itself introduces another 20:
"request": {
"version": "2.87.0",
...
"requires": {
"aws-sign2": "0.7.0",
"aws4": "1.7.0",
"caseless": "0.12.0",
"combined-stream": "1.0.6",
"extend": "3.0.1",
"forever-agent": "0.6.1",
"form-data": "2.3.2",
"har-validator": "5.0.3",
"http-signature": "1.2.0",
"is-typedarray": "1.0.0",
"isstream": "0.1.2",
"json-stringify-safe": "5.0.1",
"mime-types": "2.1.18",
"oauth-sign": "0.8.2",
"performance-now": "2.1.0",
"qs": "6.5.2",
"safe-buffer": "5.1.2",
"tough-cookie": "2.3.4",
"tunnel-agent": "0.6.0",
"uuid": "3.2.1"
}
},
You can see how it gets to 300 so quickly.