node.jsbrowserifysipgulp-browser-syncjssip

Browserify - JsSip


I have a new project where I'm using browserify to convert node modules into an sdk that can run inside the browser.

I'm requiring a number of other npm packages like:

var log4js = require('log4js');

That run fine and give me no problems in the browser, however JsSip just will not cooperate. When I do

var JsSIP = require('jssip');

I get

plivowebsdk.js:2 Uncaught Error: Cannot find module '../../package.json'

Looking through the code, it's obvious when it makes this call

var pkg = require('../../package.json');

is where it bombs out. Clearly it cannot find the package.json file, which it uses to pull out version information. I know JsSip is actually built with browersify itself (or used to be) so that it can run in either node or a browser. Is this causing a conflict?

Still sort of new to browserify, is their a configuration option or transformation I can perform to get around this?


Solution

  • Turned out the be browserify errors, re did the build process using the gulp recipes for browersify and works as expected.