CDH
CDH

Reputation: 1

Error requiring GLPK.js in React "GLPK is not a function"

I am trying to build a web app that involves solving an integer linear program (basically, I am doing constrained group assignment). In order to solve this ILP, I am trying to use the javascript porting of the GLPK library that is in npm. I installed it by doing npm i glpk.js Then, I imported the package in my function as

const foo = async () => {
     const GLPK = require('glpk.js');
     const glpk = GLPK();
     ...
}

and this gave the error

Uncaught (in promise) TypeError: GLPK is not a function

Because of the "(in promise)" part, I also tried to await the require, but this gave the same error.

Upvotes: 0

Views: 116

Answers (0)

Related Questions