title: How to implement Express + Node JS + Browserify properly?
body: <p>So I'm somewhat new to the whole web development thing with node.js and I'm wondering if someone could help me out with understanding how to implement my application correctly.</p>
  <p>So the app is a simple landing page with an email form that takes an email and sends it to the API. I designed this functionality without issue except when I launched my website i'm getting a required not defined error.</p>
  <p>I understand that this is because node.js is a server side technology so that when the application goes live, the client doesn't understand what required means.</p>
  <p>Through further research, I figured out that I had two options and that's to either implement synchronous dependencies via something like Browserify or take things asynchronously and use something like RequireJS.</p>
  <p>Right now I've decided on using Browserify, (unless someone can convince me otherwise) I just need help with figuring out how to implement it for my specific app.</p>
  <p>app.js</p>
  <pre><code>//The dependenices my node js app needs (also where the require bug occurs)
  //------------------------------------------------------------------------------------------------------------------------
  const express = require('express'); //Require the express package that we installed with npm install express
  
  const request = require('request'); //Require the express package that we installed with npm install request
  
  const bodyParser = require('body-parser'); //Require the express package that we installed with npm install bodyParser
  
  const path = require('path'); //Require the express package that we installed with npm install path
  //------------------------------------------------------------------------------------------------------------------------
  
  
  
  const app = express(); //Creates the application with express
  
  
  //Middleware
  app.use(express.json()); //Tells express to use JSON as it's input
  
  app.use(bodyParser.urlencoded({ extended: false })); //Prevents XSS, only will return if the url has specified enconding
  
  app.use(express.static(path.join(__dirname, '/site'))); //Tells the app to use the current path D:\Gaming Galaxy\Website\Website\main\site as the dir for the website
  
  console.log(&quot;The directory used is&quot;, express.static(path.join(__dirname, '/site')));
  
  app.post('/subscribe', (req, res) =&gt; { //Makes a post request to express req is the request and res is the response
      const { email, js } = req.body; //Create a constant that makes up of the request's body
  
      const mcData = { //Create a constant JSON object mcData, that contains the email from the above constant and a status message
          members: [
              {
                  email_address: email,
                  status: 'pending'
              }
          ]
      }
  
      const mcDataPost = JSON.stringify(mcData); //Turns the JSON object into a string
  
      const options = { //Sets a JSON object of a bunch of options that mailchimp will use
          url: 'https://us20.api.mailchimp.com/3.0/lists/f10300bacb',
          method: 'POST',
          headers: {
              Authorization: 'auth f24c3169da044653d1437842e39bece5-us20'
          },
          body: mcDataPost
      }
  
      if (email) { //If there's an email that exists
          request(options, (err, response, body) =&gt; { //Send a request to mail chimp
              if (err) { //If there's an error
                  res.json({ error: err }) //Print said error
              } else { //If there's not an error
                  if (js) {  //If javascript is enabled (boolean)
                      res.sendStatus(200); //Send a success message
                  } else {
                      res.redirect('/success.html'); //If it's disabled, send them to a successful HTML page.
                  }
              }
          })
      } else {
          res.status(404).send({ message: 'Failed' }) //If the email doesn't exist, have it fail
      }
  
  });
  
  app.listen(5000, console.log('Server started!')) //Console log that confirms the start of the server
  </code></pre>
  <p>package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;gaminggalaxy&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;main&quot;: &quot;site/js/app.js&quot;,
    &quot;dependencies&quot;: {
      &quot;body-parser&quot;: &quot;^1.19.0&quot;,
      &quot;commonjs&quot;: &quot;^0.0.1&quot;,
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;index&quot;: &quot;^0.4.0&quot;,
      &quot;node-fetch&quot;: &quot;^2.6.6&quot;,
      &quot;prototype&quot;: &quot;^0.0.5&quot;,
      &quot;request&quot;: &quot;^2.65.0&quot;,
      &quot;requirejs&quot;: &quot;^2.3.6&quot;,
      &quot;uniq&quot;: &quot;^1.0.1&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;nodemon&quot;: &quot;^2.0.15&quot;
    },
    &quot;scripts&quot;: {
      &quot;serve&quot;: &quot;node app&quot;,
      &quot;dev&quot;: &quot;nodemon app&quot;
    },
    &quot;keywords&quot;: [],
    &quot;author&quot;: &quot;&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;repository&quot;: {
      &quot;type&quot;: &quot;git&quot;,
      &quot;url&quot;: &quot;git+https://github.com/InvertedTNT/Main.git&quot;
    },
    &quot;bugs&quot;: {
      &quot;url&quot;: &quot;https://github.com/InvertedTNT/Main/issues&quot;
    },
    &quot;homepage&quot;: &quot;https://github.com/InvertedTNT/Main#readme&quot;,
    &quot;description&quot;: &quot;&quot;
  }
  
  </code></pre>
  <p>index.html (the form itself)</p>
  <pre><code>&lt;form action=&quot;/subscribe&quot; method=&quot;POST&quot;&gt;
     &lt;div class=&quot;newsletter-form-grp&quot;&gt;
          &lt;i class=&quot;far fa-envelope&quot;&gt;&lt;/i&gt;
          &lt;input type=&quot;email&quot; name=&quot;email&quot; id=&quot;email&quot;
                placeholder=&quot;Enter your email...&quot; required&gt;
      &lt;/div&gt;
      &lt;button id=&quot;cta&quot;&gt;SUBSCRIBE &lt;i class=&quot;fas fa-paper-plane&quot;&gt;&lt;/i&gt;&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>folder structure</p>
  <pre><code>node_modules
  site
    -index.html
    -css
    -js
       - app.js
    -images
  app.js
  package-lock.json
  package.json
  </code></pre>
  <p>Thank you for your help, I would appreciate any sort of advice on how I can use those dependencies and the overall implementation of browserify.</p>