Node library puppeteer isn't working with vue.js

Viewed 515

I was watching a youtube tutorial on how to use puppeteer in javascript and the page will not render if I require the library even if I use it or not.

It is located right below where I imported my vue components and as such looks like this:

<script>
import Header from './components/Header.vue'
import Item from './components/Item';
const puppeteer = require('puppeteer')

Checking console showed this error:

util.js?3022:602 Uncaught TypeError: The "original" argument must be of type Function
    at promisify (util.js?3022:602)
    at eval (index.js?6b55:11)
    at Object../node_modules/extract-zip/index.js (chunk-vendors.js:1642)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (BrowserFetcher.js?aafb:48)
    at Object../node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js (chunk-vendors.js:2780)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (Puppeteer.js?a657:23

Any help is much appreciated, thank you!

1 Answers

You can't use puppeteer in browser it mean to work with Node only.

Tip: Don't follow code practice from YouTube, use official document and medium blogs.

Related