Browserify: Use require() in Client Side JavaScript
Introduction
Have you ever had a moment when writing code, you are exporting and importing data into different files you have in a project? Everything is working properly and you want to show the results in the browser, but nothing is showing up? You open up the console only to end up with an error that says ReferenceError: require is not defined
? Don’t you just hate that?!!!!
Introducing Browserify. It lets you use require() in the browser by bundling up the dependencies that you have in your program. I’ll show you how to use this extension for your projects.
Getting Started
First, you have to install browserify into your project. Type this into your terminal:
npm install -g browserify
The data I will be working with is a JSON file that I will import into a file I have called recommenderP.js
.
Now I will require this data into my recommenderP.js
file: