0
votes

I'm new to node.js and I've been trying to use a function in my chrome extension that uses require - however, even after installing browserify, bundling up the modules in content.js into bundle.js, and trying to make require global with

browserify content.js --standalone Bundle > bundle.js

I'm still getting

Uncaught ReferenceError: require is not defined

Any help would be really appreciated, and I'm really sorry if this is a stupid question hahaha

1

1 Answers

0
votes

In order for it to work for me I added...

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

before the closing body call in my html page. So your html file should look something like...

<!DOCTYPE html>
<html>
    <head>
        <meta charset = "utf-8"/>
        <title> clickerance </title>
        <link type="text/css" rel="stylesheet" href="style.css"/>
        <script src="bundle.js"></script>
    </head>
    <body>
      <div class="Title"></div>
        <h1> Clickerance </h1>
 
        Dairy  : <input type="checkbox" id="Dairy"><br>
        Meat   : <input type="checkbox" id="Meat"><br>
        Corn   : <input type="checkbox" id="Corn"><br>
        Gluten : <input type="checkbox" id="Gluten"><br>
 
        <p>Which ones you can't eat?</p>
 
        <input id="Submit" type="submit" value="Submit">
    <script type="text/javascript" src="bundle.js"></script>
    </body>
</html>