1

This is my manifest:

  "background": {
    "page": "./src/background_scripts/background.html"
  },

This is my background.html:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
        </head>
        <body>
<script type="module" src="./ScrapingContent.js"></script>
    
        </body>
    </html>

this is the ScrapingContent.js:

import * as cheerio from "../../node_modules/cheerio/index.js"

But I get the error:

ReferenceError: require is not defined

Now obviosly I also need to import require, so I change my background.html to:

        <!DOCTYPE html>
        <html>
            <head>
                <meta charset="UTF-8">
            </head>
            <body>
<script type="text/javascript"src="../../node_modules/requirejs/require.js"></script>
    <script type="module" src="./ScrapingContent.js"></script>
        
            </body>
        </html>

and I get the error:

Error: Module name "lib/static" has not been loaded yet for context: _. Use require([])
https://requirejs.org/docs/errors.html#notloaded

How can I import these modules/external libraries?

user3038404
  • 331
  • 5
  • 14

0 Answers0