I am trying to bundle the bs58
module using browserify by following the instructions provided on this website:
npm install --save bs58
npm install -g browserify
browserify < /mypath/lib/bs58.js > /mypath/lib/bs85.bundle.js
In my HTML + JS file, I have included:
My understanding is that this code should allow me to access the bs58 object and use the functions encode
and decode
. However, when I try to use it, I get a
ReferenceError: bs58 is not defined
.
Examining the browserified code, it looks like this:
(function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({},{},[]);
The code does not include the word encode
as anticipated.
I'm unsure if the module was correctly installed, but the demonstration examples seem to work fine in Node (after require bs58
).
While trying to troubleshoot, several questions have arisen:
1. How can I verify if the bs58 module has been properly browserified?
2. What is the default location for lib/bs58.js
?
3. How can I access the encode
and decode
bs58 functions in the browser?
4. Are there any alternatives for base58 encoding/decoding in the browser?