Kekule.js
Kekule.js copied to clipboard
Cannot get ChemWidget in Nodejs
My JS code in Nodejs (v10.0.0):
const Kekule = require('kekule').Kekule
console.log(Kekule.ChemWidget)
const chemViewer = new Kekule.ChemWidget.Viewer(document)
console.log(chemViewer)
The problem/output I am getting:
undefined
TypeError: Cannot read property 'Viewer' of undefined
Any help?
Hi @joshuaquek, the widget/chemWidget modules are not loaded in node.js environment by default, since the HTML widgets are useless in server side. Anyway, if they are really needed, you can load the modules in node manually:
const Kekule = require('kekule').Kekule;
Kekule.modules(['chemWidget'], function(error){
if (!error) // loading successfully
{
console.log(Kekule.ChemWidget.Viewer);
}
});
Please check the latest dist files. However, there is no window or document object in node.js environment, so the widgets still can not be created and run properly.
I see, let me give it a try and I'll be able to report back here again