bonjour
bonjour copied to clipboard
Ionic 2 error, "Cannot find module dgram"
In an Ionic 2 TypeScript project, I've installed the bonjour npm module, then imported it like this:
import bonjour from 'bonjour';
That doesn't throw errors. Bt as soon as I refer to bonjour, I get the runtime error
Cannot find module "dgram"
Has anyone successfully used this plugin with Ionic 2?
I don't think this is Ionic related. I'm getting the same error with a simple NodeJS project.
I'm getting the same error on ionic 2 typescript with [email protected] using
import Bonjour from 'bonjour';
and then
Bonjour.find({ type: 'http' }, function (service) {
console.log('Found an HTTP server:', service)
})
Found an alternative here at ZeroConf Ionic Plugin, I would have preferred this "bonjour" module but I see no other alternative to go to Zeroconf.
The module dgram is not available in client side Ionic code. Ionic runs on cordova and not on the node js system which means that this package cannot be used in Ionic for the moment. The Zeroconf Ionic plugin is a great alternative, though it is only suited for ios and android.
When programming with the zeroconf plugin, you can use safari to debug when you run on an ios device. Find the 'developer' menu in settings and you can see your device listed there.
When you can't run on a device but in a browser, look up 'mock' to 'imitate' a service being added so you can develop the things you need.
Hi,
I went into the dgram folder and it is pretty empty (just a readme) :
This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.
You may adopt this package by contacting [email protected] and requesting the name.
So as suggested I wrote to npm, and they answered :
Thanks for reaching out!
The dgram package on npm was empty and didn't do anything, however many packages mistakenly depended on it. npm, Inc. has taken ownership of it.
It's also a built-in Node module. If you've depended on dgram, you can safely remove it from your package dependencies.
You can learn more about dgram in Node here: https://nodejs.org/api/dgram.html
And so I went to the web site suggested but it doesn't seems it was empty actually....
Whatever, I tried to comment out things with dgram ( in multicast-dns package ) or tweek it but it seems it was useful at some points.
SO, so, i don't know what to do with that haha. I'll go to multicast-dns see what may be done.