Require is not defined in algebra.min.js (for browser use)
dominik0711 opened this issue · 1 comments
Hi.
As you described in the ticket 56 and ticket 57 the latest version of algebra.min.js
should work in the browser (in my case chrome
) but it didn't due to the fact that you are using require.
This is the error:
Uncaught ReferenceError: require is not defined
Neither the minified nor the created version from zip is working as expected.
Additionally you are pointing to ./src/
folder in the algebra.min.js
file which is definitely NOT available.
Could you or someone else give me a hint how to solve this problem?
I have tested the algebra.min.js
version 0.2.4 in chrome browser version 51.0.2704.103
Thanks in advance!
Browserify bundles source files that use require()
with relative paths into a single standalone file. Read more here. Specifically:
Each file is concatenated into a single javascript file with a minimal require() definition that maps the statically-resolved names to internal IDs.
I've added the version to the file available at http://algebra.js.org/. Can you grab algebra-0.2.5.min.js
and confirm it still doesn't work? I have it working as a standalone file in both Chrome and Firefox, evidenced at http://algebra.js.org/ if you open up the console in either browser and use the library. Please make sure you're using the correct path in your script tag and that you're actually defining Fraction, Expression, and Equation.
<script src="algebra-0.2.5.min.js"></script>
<script>
var Fraction = algebra.Fraction;
var Expression = algebra.Expression;
var Equation = algebra.Equation;
</script>
Alternatively, you could just use them off the algebra
object:
var f = new algebra.Fraction(1, 2);
f.toString();
var e = new algebra.Expression("x");
e = e.add(f);
var eq = new algebra.Equation(e, 2);
eq.toString();
x = eq.solveFor("x");
x.toString();