When I add 'htmlparser2' (v 4.1.0) to my project and only import/require it, Velo chokes in Preview Mode. In Publish mode, I see the following error (both on import or require):
Cannot find module 'events' in 'htmlparser2/lib'
What am I doing wrong here?
//Test1 with import
//import * as htmlparser2 from "htmlparser2";
$w.onReady(function () {
//Test2 with require
// var htmlparser = require('htmlparser2')
console.log("Hello world");
});
Worked it out: turns out that on Velo, this NPM can only be used on the backend.