Receiving and error for https in react-native - http

I am receiving the following error message:
error: bundling failed: Error: Unable to resolve module 'http' from
'some/path/to/iugu.js': Module 'http' does not exist in the Haste module map
I'm following this documentation for using iugu:
https://github.com/iugu/iugu-node
var iugu = require('iugu')(
'fa484a7c14ff046c6f1c589d2f0c389b',
'latest'
);

That module is not fully compatible with React Native.
Some node modules are automatically available via require() like http, crypto, etc. These modules are available in Node, but they are not automatically available in other environments such as browsers and in this case React Native.
To use your package seems that you need to include a compatible http implementation.
There are some ways to kind of "Nativeify" those modules and to include those node core libraries in React Native. Take a look to ReactNativify and also this article Using Core Node JS Modules in React Native Apps.

Related

Module resolution not consistent with esm and non esm files

I have a project setup where I have a web app that rely on few Firebase SDKs that is Webpacked and served via webpack dev server.
From what I could gather without getting into too much details is that there is a final dependency that have both general index, and es2017 index files
there are intermediate dependencies that also have both, like the app and some that have only es2017 for example the messaging, and some only general index files.
The problem I have is that, and I have debugged for a very long time, from my application level when I import an intermediate dependency in different files, in some cases it takes the general index file, and in some the es2017 of the same library.
So in the error stacktrace here I am trying to initialize the messaging service of Firebase: (ignore for a moment the missing promise reject)
at Provider.getImmediate (index.cjs.js:153) // in component lib
at Module.getMessagingInWindow (index.esm2017.js:1155) // in messaging lib
at new MessagingWrapper (MessagingWrapper.js:76) // in my application
at FirebaseSession.push.56916.FirebaseSession.getMessaging (FirebaseSession.js:96)
at PushPubSubModule_Class.<anonymous> (PushPubSubModule.js:118)
at step (PushPubSubModule.js:63)
at Object.next (PushPubSubModule.js:44)
at fulfilled (PushPubSubModule.js:35)
When the messaging module is initially loaded it also accessed the component lib and uses the correct es2017 index file, but at a later point when I am trying to actually get the instance of the Messaging service it goes to the other general index file.
in all cases I use the import the same as in import {somthing} from "#firebase/messaging"
I never really had to worry about these things and might miss something fundamental, but this feels like a webpack bug in predetermine which module to load from the nested lib...
do you know of a way I could FORCE webpack to resolve es2017 index file?
or should I open a bug?
More details:
This is the transpiled code of my MessagingWrapper file:
line 71: goes to the correct es2017 index file in the messaging lib and the correct es2017 in the component lib
where as line 76: goes to the correct es2017 index file in the messaging
line:
and here line 1155: actually goes to the firebase/app lib es2017 file to resolve the provider, comes back to line 1155 and then call to getImmediate which ends up in the general index file in the component lib, as you can see below:
How do I fix this?
#firebase/* packages are internal and you shouldn't be importing them within your code as warned on each of their npm directory listing. As you encountered, this can lead to issues with module resolution as you essentially skip the internal setup steps by accessing the internals directly.
Instead, use the public API interfaces via firebase/* (for the modular SDK on v9+ or legacy SDK v8 and lower) and via firebase/compat/* (for the legacy SDK on v9+).

Google Cloud Vision API could not find a declaration file

I'm following this tutorial that uses Ionic framework and Firebase backend to create an image recognition app https://www.youtube.com/watch?v=taPczl94Eow
For this line:
import * as vision from '#google-cloud/vision'
I keep getting the error:
Could not find a declaration file for module '#google-cloud/vision'.
'/Users/Private/Workspace/project/functions/node_modules/#google-cloud/vision/src/index.js' implicitly has an 'any' type.
Try `npm install #types/google-cloud__vision` if it exists or add a new declaration (.d.ts) file containing `declare module '#google-cloud/vision';`
What should I do? I already installed it properly. I also enabled the API from the GCP platform and followed their instructions
I was also having the same problem, so I had to replace this line:
import * as vision from '#google-cloud/vision'
For this line (it works with Typescript):
const vision = require('#google-cloud/vision');
I hope this works for your case.

Firebase is not Importing without cocoapods in Xcode

I am new at Swift. I am creating my own framework that will use Firebase for in-app messages.
I tried to install Firebase through Cocoa pods, but it has issues: when I do that for my framework, then for sample project I have to install Firebase again. And then I get the numbers of warnings like this:
Class Firebase is implemented in both /private/var/containers/Bundle/Application/AD85D7EC-2652-4019-94FB-C799D0FBA69B/MyFrameworkExampleApp.app/Frameworks/MyFramework.framework/MyFramework (0x1019a0438) and /var/containers/Bundle/Application/AD85D7EC-2652-4019-94FB-C799D0FBA69B/MyFrameworkExampleApp.app/MyFrameworkExampleApp (0x10107c558). One of the two will be used. Which one is undefined.
my app crashes at runtime due to these warnings
So I don't want to use cocoa pods in Framework but need Firebase in my project.)
.
I follow the steps:
"https://firebase.google.com/docs/ios/setup#frameworks"
I just download the firebase file and import it into my project. after this I try to:
import Firebase
at the top of my swift class but the compiler is giving me an error.
No such module 'Firebase'
I am using Xcode 9. swift 4.
All of the framework files are in
"Targets > FrameworkName > General > Linked Frameworkd and Libraries".
also in the
"Targets > FrameworkName > Build Phases > Link Binary with Libraries".
I also followed this tutorial:
http://www.mokacoding.com/blog/setting-up-firebase-without-cocoapods/
but nothing happened.
Where am I wrong and What should I do?
Try adding following #import to framework's public header file "YourCocoaTouchFrameworkNameSwift.h"
#import <YourCocoaTouchFrameworkName/Firebase.h>
Check this link, if you need more information.
in firebase we have not a .framework file for import firebase. As we know that firebase is a combination of different frameworks, so we were unable to import firebase directly. thats why we
import required framework and dependent framework separately.
Dont try to import whole firebase.

Ionic using PounchDB fail

I`m testing PounchDB for my new app and, i receive this error when try execute this code:
PouchDB.plugin(require('pouchdb-adapter-cordova'));
_db = new PouchDB('mydb.db', {adapter: 'cordova-sqlite'});
Erro received:
ReferenceError: Can't find variable: require
I follow instructions from: https://github.com/nolanlawson/pouchdb-adapter-cordova-sqlite
Using ionic 1.
You're using require without an associated package manager or module bundler. require is not native to JavaScript -- you have to include a library or package your app in order for this to work.
I suggest JSPM (http://jspm.io), since it works with SystemJS and supports the newest ES2015 module syntax. However, it also understands require.
Alternatively, you can use Browserify(http://browserify.org) to bundle your code (essentially Browserify packs everything into one file, which is great for production!). Webpack(https://webpack.github.io) is also a great option. Both of these will add a build step to your development workflow, so be aware of that (but you should have one anyway).

What is __meteor_bootstrap__?

I am just starting with Meteor and working on an existing project. I am running into an issue with one of the packages(observatory-apollo) that's has the following line:
__meteor_bootstrap__.app.use Observatory.logger #TLog.useragent
It is complaining that __meteor_bootstrap__.app is undefined.
What is __meteor_boostrap__ exactly? I can't seem to find a description of what it is but from threads, people seem to know how to use it. I can only see it defined in boot.js, but it doesn't really tell me much...
Meteor uses connect npm module under the hood for various reasons, to serve static files, for example. __meteor_bootstrap__.app was the reference to connect app instance.
Before it was __meteor_bootstrap__.app but it changed couple of releases ago and became WebApp.connectHandlers object and is part of WebApp package.
WebApp is a standard package of Meteor, core package for building webapps. You don't usually need to add explicitly as it is a dependency of standard-app-packages.
Example of usage the connectHandlers is to inject connect middlewares in the same way as you would use any connect middleware (or some express middlewares, express is built on top of connect):
WebApp.connectHandlers
.use(connect.query())
.use(this._config.requestParser(bodyParser))
You can look at meteor-router Atmosphere package and take it as an example: https://github.com/tmeasday/meteor-router/blob/master/lib/router_server.js
More about connect: https://npmjs.org/package/connect

Resources