RxJS module give error after update. how to solve? - import

In my angular 5 project. My imports have been producing weird errors that I cant remember having a few days ago. For the import here below it says: "module ...rxjs/observable has no exported member observable".
import { Observable } from 'rxjs/Observable';
I did not have this before.
Funny thing is however, the angular website, including the functionality with the observable, works just fine
Here is my package.json:
"private": true,
"dependencies": {
"#angular-devkit/core": "0.0.29",
"#angular/animations": "^5.2.0",
"#angular/cdk": "^5.2.5",
"#angular/common": "^5.2.0",
"#angular/compiler": "^5.2.0",
"#angular/core": "^5.2.0",
"#angular/forms": "^5.2.0",
"#angular/material": "^5.2.0",
"#angular/material-moment-adapter": "^5.2.5",
"#angular/platform-browser": "^5.2.0",
"#angular/platform-browser-dynamic": "^5.2.0",
"#angular/router": "^5.2.0",
"bootstrap": "^4.0.0",
"core-js": "^2.4.1",
"jsonwebtoken": "^8.2.0",
"moment": "^2.20.1",
"moment-duration-format": "^2.2.2",
"npm": "^5.6.0",
"rxjs": "^5.5.12",
"zone.js": "^0.8.19"
},

Unfortunately, I do not know how to solve the import problem. However, I think it might be worth mentioning that I experienced a similar issue when updating to the latest version for Angular 6, that is to say rxjs 6.3.0. So I downgraded to 6.2.1, which made the import errors go away.

Related

Working example of #nativescript/firebase-firestore

I am trying to use the #nativescript/firebase-firestore and #nativescript/firebase-core plugin from Nativescript in my Nativescript angular project.
I ran
npm install #nativescript/firebase-core
npm install #nativescript/firebase-firestore
and put this code to my blank native script angular project.
import { firebase } from '#nativescript/firebase-core'
import '#nativescript/firebase-firestore'
const firestore = firebase().firestore()
I was not able to make this work for IOS due to some compatibility issues.
My questions : Has anybody put this to work and could provide me a working example?
Here is my package.json :
{
"name": "fb3",
"main": "./src/main.ts",
"version": "1.0.0",
"private": true,
"dependencies": {
"#angular/animations": "~15.0.0",
"#angular/common": "~15.0.0",
"#angular/compiler": "~15.0.0",
"#angular/core": "~15.0.0",
"#angular/forms": "~15.0.0",
"#angular/platform-browser": "~15.0.0",
"#angular/platform-browser-dynamic": "~15.0.0",
"#angular/router": "~15.0.0",
"#nativescript/angular": "~15.0.0",
"#nativescript/core": "~8.4.0",
"#nativescript/firebase-core": "^2.5.2",
"#nativescript/firebase-firestore": "^2.5.2",
"#nativescript/theme": "~3.0.2",
"rxjs": "~7.5.0",
"zone.js": "~0.11.5"
},
"devDependencies": {
"#angular-devkit/build-angular": "~15.0.0",
"#angular/compiler-cli": "~15.0.0",
"#nativescript/ios": "8.3.3",
"#nativescript/types": "~8.4.0",
"#nativescript/webpack": "~5.0.12",
"#ngtools/webpack": "~15.0.0",
"typescript": "~4.8.4"
}
}
It seems that there are issues with min required iOS version is 11.0 so I added
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
to my build.xcconfig.

Ionic native Http post not working in IOS

I need help in resolving this issue. I’m facing issue when doing POST request to get the access token in IOS. Whereas it works fine in Android.
I'm using the Cordova plugin cordova-plugin-advanced-http: "^2.4.1".
Code:
const bodyParams = {‘client_id’:clientId,‘client_secret’:secret,‘grant_type’:‘authorization_code’,‘code’:tokenOrCode};
const httpResponse = await this.http.post(accessTokenUrl, bodyParams, {“Content-Type”: “application/json”});
Error:
{“error”:“invalid_client”,“error_description”:“FBTOAU204E An invalid secret was provided for the client with identifier: ‘abc#abc.com’.”}
Note: The above code works without any issues in Android.
Package.json:
"#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/http": "^5.2.0",
"#ionic-native/network": "^5.24.0",
"#ionic-native/secure-storage": "^5.2.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^4.1.0",
"ajv": "^6.10.0",
"cordova-ios": "^4.5.5",
"cordova-plugin-advanced-http": "^2.0.9",
"cordova-plugin-cookiemaster": "^1.0.5",
"cordova-plugin-device": "^2.0.3",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^3.0.0",
"cordova-plugin-network-information": "^2.0.2",
"cordova-plugin-secure-storage": "^3.0.2",
"cordova-plugin-splashscreen": "^5.0.3",
"cordova-plugin-statusbar": "^2.4.3",
"cordova-plugin-whitelist": "^1.3.4",
"core-js": "^2.5.4",
"rxjs": "~6.3.3",
"zone.js": "~0.8.29"
Before sending post request set serializer as per your request :
For json :
this.http.setDataSerializer("json");
const bodyParams = {‘client_id’:clientId,‘client_secret’:secret,‘grant_type’:‘authorization_code’,‘code’:tokenOrCode};
const httpResponse = await this.http.post(accessTokenUrl, bodyParams, {“Content-Type”: “application/json”});
I was having a problem similar to your problem like request was working on Android, was not working on Ios. (Ionic 5 - Capacitor App)
I fixed my problem to changing my content-type.
It may help you too, please try it.
{“Content-Type”: “application/json”}
Replace with the following
{“Content-Type”: “application/x-www-form-urlencoded”}

Error: “Unresolved function or method present()” when using LoadingController

ISSUE:
When I use the LoadingController in my project, I see the following error: "Unresolved function or method present()"
Here is the screenshot code that I have in my file:
As we can see from the screenshot, there are 2 pieces of code that show the same error. The code from lines: 51-61 are a direct copy of the code from the ionic documentation that can be seen under Usage
The code from lines: 63-69 are the trimmed down and basic version of the code and for testing purposes await is removed in front of the loading.present();. Yet it throws the same error as the original code above.
GOAL:
What can we do to fix the issue so that Intellij Idea (IDE) stops complaining about the same?
Following is the info from my package.json:
{
"name": "gf",
"version": "0.0.1",
"author": "Ionic Framework",
"homepage": "https://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": "~8.1.2",
"#angular/compiler": "~8.1.2",
"#angular/core": "~8.1.2",
"#angular/forms": "~8.1.2",
"#angular/platform-browser": "~8.1.2",
"#angular/platform-browser-dynamic": "~8.1.2",
"#angular/router": "~8.1.2",
"#ionic-native/core": "^5.0.0",
"#ionic-native/splash-screen": "^5.0.0",
"#ionic-native/status-bar": "^5.0.0",
"#ionic/angular": "^4.7.1",
"#ionic/storage": "^2.2.0",
"cordova-sqlite-storage": "^3.2.1",
"core-js": "^2.5.4",
"rxjs": "~6.5.1",
"tslib": "^1.9.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"#angular-devkit/architect": "~0.801.2",
"#angular-devkit/build-angular": "~0.801.2",
"#angular-devkit/core": "~8.1.2",
"#angular-devkit/schematics": "~8.1.2",
"#angular/cli": "~8.1.2",
"#angular/compiler": "~8.1.2",
"#angular/compiler-cli": "~8.1.2",
"#angular/language-service": "~8.1.2",
"#ionic/angular-toolkit": "~2.0.0",
"#types/jasmine": "~3.3.8",
"#types/jasminewd2": "~2.0.3",
"#types/node": "~8.9.4",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.15.0",
"typescript": "~3.4.3"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-sqlite-storage": {}
}
}
}
No sure it is the right way to do it but i managed to Intellij to stop whining
return (<any>loading).present();

How to stop ionic cordova run android command delete existing ionic apps on the device

I'm new to the forum and need help on running/installing ionic 3 app on a real device.
This command: ionic cordova run android (in my case) will delete the existing ionic app being installed on the device even though the app names are different.
I'd tried using ionic cordova run android --prod --release but the result is the same, i.e. Only ONE ionic app will be installed on the Android device which doesn't sound right.
Is there a way to prevent that from happening? Any options? Below is my package.json file:
"dependencies": {
"#angular/common": "5.0.3",
"#angular/compiler": "5.0.3",
"#angular/compiler-cli": "5.0.3",
"#angular/core": "5.0.3",
"#angular/forms": "5.0.3",
"#angular/http": "5.0.3",
"#angular/platform-browser": "5.0.3",
"#angular/platform-browser-dynamic": "5.0.3",
"#ionic-native/core": "4.4.0",
"#ionic-native/splash-screen": "4.4.0",
"#ionic-native/status-bar": "4.4.0",
"#ionic/pro": "1.0.16",
"#ionic/storage": "2.1.3",
"cordova-android": "6.3.0",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-ionic-webview": "^1.1.16",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-whitelist": "^1.3.1",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
"rxjs": "5.5.2",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.18"
},
Have you changed the package name of that App? This issue happened when package name of Apps are same.

DefinitelyTyped Typescript Definition doesn't recognize mongoose dependencies

I'm using TypeScript, Angular 2 and mongoose. I installed mongoose using NPM:
"dependencies": {
"#angular/common": "2.0.0-rc.6",
"#angular/compiler": "2.0.0-rc.6",
"#angular/core": "2.0.0-rc.6",
"#angular/forms": "2.0.0-rc.6",
"#angular/http": "2.0.0-rc.6",
"#angular/platform-browser": "2.0.0-rc.6",
"#angular/platform-browser-dynamic": "2.0.0-rc.6",
"#angular/router": "3.0.0-rc.2",
"#angular/upgrade": "2.0.0-rc.6",
"body-parser": "^1.15.2",
"bootstrap": "^3.3.6",
"core-js": "^2.4.1",
"express": "^4.13.4",
"jquery": "^3.1.0",
"mongoose": "^4.6.0",
"morgan": "^1.7.0",
"path": "^0.12.7",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.11",
"systemjs": "0.19.27",
"typescript": "^2.0.0",
"typings": "^1.3.2",
"zone.js": "^0.6.17"
},
"devDependencies": {
"jasmine-core": "^2.5.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "^1.0.2"
}
Of course, mongoose installs mongodb as a dependency. I then installed the mongoose DefintielyTyped definitions using command typipngs install dt~mongoose --global --save. That installs the mongoose index file:
// Generated by typings
// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/51c51f03549a63f8791865bf26480947e22f4902/mongoose/mongoose.d.ts
declare module "mongoose" {
import events = require('events');
import mongodb = require('mongodb');
import stream = require('stream');
import mongoose = require('mongoose');
etc., etc. When I run tsc, I get the following error: typings/globals/mongoose/index.d.ts(5,28): error TS2307: Cannot find module 'mongodb'. It doesn't feel right to npm install mongodb --save since it is already installed with mongoose.
What is the right way of fixing this?
It's not asking you to install the module, it's asking you to install the typings for mongodb. Typings by default do not install dependency typings. So you have to go through and install each dependencies manually.
Specifically for Mongoose, you are going to need the typings for mongodb, mpromise and mongoose-promise (I think that's all of them).