yjay
November 24, 2020, 7:55pm
1
I’m using the mljs library and I’m trying to figure out how to properly import for node.js.
In javascript it is:
`import { DecisionTreeClassifier as DTClassifier } from 'ml-cart';`
I tried in node.js:
const DecisionTreeClassifier= require('ml-cart');
but I’m getting an error:
TypeError: DecisionTreeClassifier is not a constructor
The node modules looks like:
any ideas would be great, thanks!
const MLCart = require('ml-cart');
// or whatever you want to call it
// Use it
MLCart.DecisionTreeClassifier
Or this:
const DTClassifier = require('ml-cart').DecisionTreeClassifier
The ESModules import is you importing a specific named function called DecisionTreeClassifier, the syntax you’re trying for Common JS imports is for a default export.
1 Like
yjay
November 25, 2020, 7:05pm
3
@DanCouper Thanks so much!