Closed mensch72 closed 5 years ago
Instead of doing:
declare var require: any;
require('@cloudant/cloudant');
try
import * as Cloudant from '@cloudant/cloudant'
I think the declare var require: any;
statement is killing the require
function. See https://www.typescriptlang.org/docs/handbook/modules.html
I don't think isn't a nodejs-cloudant issue, just a problem with your TypeScript code.
When doing this, the import works, but as soon as I try using the API, I still get the same error.
My src/app/app.component.ts
now looks like this:
import * as Cloudant from '@cloudant/cloudant'
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
@Component({
selector: 'app-root',
templateUrl: 'app.component.html'
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar
) {
this.initializeApp();
let cloudant_username = "some valid username",
cloudant_password = "some value password";
let cloudant = Cloudant({ account:cloudant_username, password:cloudant_password });
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
}
I suspect the issue must be related to nano
, since if I try requiring either nano
or cloudant-nano
instead of @cloudant/cloudant
, I get the same kind of error.
Hello - I've been able to reproduce this problem. The errors I'm seeing are similar to https://github.com/ionic-team/ionic/issues/4986. The issue comments suggest that including third party libraries works only for selected modules.
Unfortunately we don't provide support for using nodejs-cloudant as part of an ionic project. If you manage to resolve the problem please update this issue with your fix.
Thanks.
Bug Description
1. Steps to reproduce and the simplest code sample possible to demonstrate the issue
node -e 'require("@cloudant/cloudant"); console.log("Cloudant works");'
var Cloudant = require('@cloudant/cloudant');
in some ionic page's typescriptionic serve
from the command lineE.g.,
this should work (then terminate running server by ctrl-C).
which should report
Cloudant works
just fine.src/app/app.component.ts
:and
ionic serve
again. This gives the errors stated below.2. What you expected to happen
The app should compile and show up in the browser.
3. What actually happened
App does not compile, with error as follows:
and so on.
Environment details
I'm using node 10.15.1, npm 6.8.0, @ionic/angular@4.0.1, @ionic/core@4.0.1 on Ubuntu 18.04