I crawled some contents by JavaScript, and want to print it on HTML.
JavaScript code below is named 'js.js'(worked well on CMD)
var request = require('request');
var cheerio = require('cheerio');
request('...URL...', function (err, res, body) {
    if (err) console.log('Err :' + err);
    var $ = cheerio.load(body);
    $('.class').each(function () {
        var content = $(this).find('.abc').text().trim();
        document.write(content);
    });
});  
But "error:require is not defined" was printed, so I looking for solutions.
I found this page and follow advice which said that use webpack or browseify.
new code(2MB after bundled) give me 2 new error:"fail to fetch" and "access-control-allow-origin". What should I do?
 
     
    