Closed marnen closed 7 years ago
On second thought, it may not be only a question of NPM vs. Bower. I note that even with Bower, I get the same error mentioned above when I do let Viz = require('viz.js')
, instead of just letting Viz
be a global variable.
This isn't ideal. I don't like global variables, and Viz really should be a well-behaved module like any other.
Viz.js detects module.exports and will use that if present. Otherwise, it sets a global variable.
Following the Brunch tutorial, this initialize.js
works for me if I install Viz.js 1.4.1 using npm. Note that I'm not using the Viz
global.
let vizJs = require('viz.js');
console.log(vizJs("digraph { a -> b; }"));
I'm using Brunch to build a JavaScript project that depends on Viz.js. When I include Viz as a Bower package, it works fine, but when I include it as a NPM package, I get the following error at build time:
TypeError: Cannot read property 'split' of undefined
. (Other NPM packages do not have this problem with Brunch.) Any idea what's going on?