I'm unable to use a node.js module on my website with broweserify. The example only shows how to run a javascript file that is separate from the .html file, not how to use the node.js module within the .html file. Seems like a trivial problem, but I'm unable to make it work.
Here's what I've done:
- Initialized node.js & installed a package,
npm i webtorrent-healthas an example - Created
require_stuff.jswhich consists of a single line:var WebtorrentHealth = require('webtorrent-health') - Run browserify:
browserify require_stuff.js > bundle.js - Include package in my html document, e.g.
<script src='bundle.js'></script> - Use the package somewhere in my document, e.g. like this:
<script>webtorrentHealth(magnet).then(foobazbar())</script>
Despite bundle.js executing and seemingly defining webtorrentHealth, the script within the .html document fails with WebtorrentHealth is not defined. What am I doing wrong? How do I make it work? Thank you!