Remove underscores from a project utilizing browserify

I am currently working on a npm project and trying to ensure it is browser-compatible with browserify. One of the dependencies in this project is underscore. In order to build the project using browserify without including underscore in the final file, I have configured my grunt settings as follows:

options: {
    exclude: {
        'underscore'
    }
}

By implementing this configuration, I have managed to reduce the size of the destination file (approximately the size of underscore). However, after attempting to run the project in a browser, I encountered the following error:

Uncaught Error: Cannot find module 'underscore'

It's worth noting that I received this error even when I had already included underscore before incorporating my project (using a <script> tag).

Does anyone know how I can instruct browserify to recognize that underscore will be loaded externally by myself?

Answer №1

Surprisingly, the task was simpler than expected. All I had to do was swap out exclude with ignore. Browserify handled the rest seamlessly :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Attempting to alert a particular device using Flutter for notification delivery

Currently, I am developing a Chat app using Flutter and attempting to send notifications to specific devices through Firebase functions. Initially, I retrieve the device token and store it in Firebase. Now, my challenge lies in fetching the token and invok ...

How come the array's length is not appearing on the browser screen?

Code: initialize: function() { this.todos = [ {id: 100, text: 'Rich'}, {id: 200, text: 'Dave'} ]; }, activeTodos: function() { this.todos = this.todos.length(function() { return this.todos; }); ...

What sets apart the method of assigning event handlers using bind() versus each() in jQuery?

Could someone explain the difference between using bind() to assign event handlers and using each() for the same task? $(function () { $('someElement') .bind('mouseover', function (e) { $(this).css({ ...

Retrieving data from a JSON object using JavaScript

{ "questions_id":[ "7", "9", "2" ], "select_param_type":[ "is greater than", "is less than", "is less than" ], "select_param_value":[ "2", "4", "2" ], "radio_type":[ "and", ...

Refresh web content dynamically without having to reload the entire page using JavaScript

Currently, I am struggling to find a solution on how to dynamically update a section of a webpage using JavaScript when a user modifies an input field in another part of the same page. Unfortunately, my use of document.write is inhibiting me from making th ...

Issue encountered: Vue js and d3 data visualization error - "d3 is not defined"

I am attempting to showcase a .json file as a treemap by using npm run dev. I thought I had everything set up correctly but it appears that an issue is arising. Below is my App.vue code: <template> <div id="app"> <title> { ...

Error in VueJS occurring following the import of a function into a JavaScript file

I've created a JavaScript script for sending data to a database, and I want to import it into my .vue file so that I can use it on button click. However, when I import the script, Vue displays the following error message and nothing appears on the pag ...

What is the best way to manage the back button using jQuery?

I'm currently facing a challenge when it comes to managing the Browser's History. While plugins like History.js can be helpful for smaller tasks, I find myself struggling with more complex scenarios. Let me provide an example: Imagine I have a m ...

Open a web browser and continuously monitor the updates by using the `tail

Currently, I have developed a Python script that continually monitors a logfile for modifications (similar to the tail -f command) and showcases it on a console. I am interested in accessing the Python script's output through a web browser. What tools ...

Get rid of the title on Superfish Menu in Drupal 7

Exploring Drupal for the first time, I've been able to find solutions to all my queries except one - removing the "Main Menu" header from my superfish menu. The region called superfish has successfully had superfish added to it, but I'm unable t ...

Working with React, with the choice of incorporating jsx or not

I am currently delving into the world of React and found myself able to run a simple app without using JSX. In my JavaScript file, I started with: class TestClass extends React.Component Do I really need to utilize JSX or can I just stick with JavaScript ...

Tips for updating the position on a website using AJAX

I am developing a website that pulls data from a MySQL database and showcases it on a map. How can I implement an automatic data refresh on the webpage every second? Should I incorporate my AJAX code within a timer function? Do I need to put the PHP scri ...

What is the best way to ensure that the buttons remain in place once they have been clicked to reveal a drop-down menu?

Is there a way to keep 3 buttons inline and prevent them from moving when clicked to open a submenu? Changing their positions results in them stacking on top of each other. Any help or suggestions would be greatly appreciated, thank you! Here is the code ...

The issue at hand is that one of the JavaScript buttons is functioning properly, while the other is not playing the video as intended. What steps can

I've been working on a script for my school project website that should make buttons play videos, but I'm running into an issue where it only works for the first button (btn). Programming isn't my strong suit, and I put this together based o ...

Implementing USB trigger for cash drawer in web development

I am wondering about how to use a USB trigger to open a cash drawer (BT-100U). Can someone provide guidance on integrating this into a website? Here is a brief description of the BT-100U Cash Drawer Driver Trigger with USB Interface: This device allows fo ...

What is causing my axios request to not retrieve the correct data?

My axios instance is set up to connect to an API that has a login route. When I test the API using Postman, everything works perfectly and it returns JWT access and refresh tokens for valid credentials. However, when I try to login through my app using axi ...

When running fs.rmSync on Ubuntu, an error is thrown stating that undefined is not a

Attempting to remove a basic folder that contains another nested folder, such as: /tmp/ac6c1fcaeae0c7ec4d1a8/res. Here is the code I am using: module.exports.deleteFolder = (path) => { try { if (fs.existsSync(path)) { console.lo ...

Installing npm populates the node_modules directory with unnecessary dependencies

I am attempting to set up Grunt on a project locally, but encountering issues when I run the following command: npm install grunt-contrib-watch The output is as follows: sass-test username$ npm install grunt-contrib-watch --save-dev [email&# ...

"Transitioning from jQuery to Vanilla Javascript: Mastering Scroll Animations

I'm seeking guidance on how to convert this jQuery code into pure Javascript. $('.revealedBox').each(function() { if ($(window).scrollTop() + $(window).height() > $(this).offset().top + $(this).outerHeight()) { $(this).addCla ...

Recording a message from an HTML input using NodeJS and socket.io

I am currently working on a project where I want to log user input from an input box to the NodeJS console. For example, if a user types "Hello world" into the input box and clicks "Send message to console", I want it to show up as "Hello world" in the con ...