Use require() on client-side JS webpage ('promisify is not a function' error with browserify)

后端 未结 1 1571
忘了有多久
忘了有多久 2021-01-27 13:55

I\'m trying to create a simple webpage that uses Puppeteer (a NodeJS library for web scraping). I can\'t run my page because my main.js file that I link to from my index.html us

1条回答
  •  梦毁少年i
    2021-01-27 14:05

    Browserify solves the problem of require not being supported by browsers.

    It also allows you to use tools like npm and yarn to manage JS packages since it can resolve them using require like Node.js can.

    It doesn’t solve the problem of modules, like puppeteer, depending on APIs that are provided by Node.js and not by browsers. You can’t run Puppeteer client-side.

    0 讨论(0)
提交回复
热议问题