Ionic 2 cannot find module 'dgram'

WJM

I have installed a template Ionic 2 application and want to add the NPM package bonjour

After installing and including the package in my component like this:

var Bonjour = require('bonjour');
var bonjour = new Bonjour();

The application won't run stating 'cannot find module dgram'

The application has both the bonjour package and bonjour types installed.

The problem

The application can't find the module dgram which is located in the @types/node file. The project is running TS 2.4.2 and should not need any references to the @types, this should be picked up automatically.

What have I tried

I tried including the @types folder anyway in multiple ways, by setting typeroots or types in the ts.config.json file. This didn't change anything.

I tried specifying types :

"types": ["node", "bonjour"]

I tried reinstalling all node modules and clearing the cache

I tried including a reference path in my component above the require statement:

/// <reference path="node_modules/@types/node/index.d.ts" />

var Bonjour = require('bonjour');
var bonjour = new Bonjour();

This all did not help. Any ideas on how to make my application load this module properly?

WJM

The package Bonjour has a DatagramPlugin which require dgram to function properly. In Ionic 2 this package is not available. The solution is to use the Native Zeroconf package as an alternative.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Ionic 2 - Runtime error Cannot find module "."

Runtime Error Cannot find module "ionic-native" IONIC 2

IONIC 2 - Runtime Error. Cannot find module “ionic-native”

Dynamic Environment Variables in Ionic - Cannot find module

Cannot find module generated with “Ionic g provider”

Cannot find module "ionic-native"

Ionic => Runtime error: Cannot find module "."

Ionic/Angular Issue Cannot find module './fs'

Cannot find Ionic-angular module

Error: Cannot find module "angularfire2/database-deprecated" appmodule ionic 3, Angularfire2

TS2307: Cannot find module 'ionic/ionic'

ionic2 provider "cannot load module"

Cannot find module "d3" error is displayed after i upgraded my project from ionic 2 to ionic 3

Cannot find Injectable name in Ionic 2

Ionic 2: Cannot find name 'SQLite'

Error: "Cannot find module" when cloning Ionic 4 component with StencilJS

Cannot find module '@ionic-native/power-management/ngx'

Ionic Uncaught Error: Cannot find module "." when importing a service provider

ionic cordova build android Cannot find module '../pages/Wallet/'

Error: Cannot find module '@ionic/app-scripts'

Error: Cannot find module "rxjs/operators" in Ionic Angular

Ionic3 - Uncaught Error: Cannot find module '.'

Ionic 3: Build in “prod” mode: Cannot find module “.”

Ionic 3 Angular 4 Cannot find module `jsonwebtoken`

Cannot find module 'read' when using ionic start

Ionic firestore Cannot find module "@angular/fire/firestore"

Cannot find module '@ionic-native/Camera/ngx'

Ionic Cordova Build prod: Cannot find module “.” - Typescript version >3

Error: Cannot find module 'symbol-observable' in Ionic 4