0

sorry i'm a complete neoobie in this but in a chrome extension I try to use puppeteer in my background.js like:

const puppeteer = require('puppeteer');

and the background.js is in my manifest.json like:

"background": {
    "service_worker": "background.js"
  },

so I have installed browserify and generated my bundle package with:

browserify background.js -o bundle.js

and im including it in my html file like:

\<!-- popup.html --\>
\<!DOCTYPE html\>
\<html\>
\<body\>
\<script src="bundle.js"\>\</script\>
\<script src="popup.js"\>\</script\>
\</body\>
\</html\>

but it still gives me the "Uncaught ReferenceError: require is not defined" error

so it can't be used in a background.js?

ive tried also:"

browserify -r puppeteer > bundle.js

and adding like this:

<script type="text/javascript" src="bundle.js"></script>

what im missing? , im specting to use puppeteer in the background.js whats the recommendation?

0 Answers0