Browserify is unable to locate the 'jquery' module

While attempting to package my app with browserify, I encountered the following error message:

Cannot find module 'jquery' from '/home/test/node_modules/backbone'

I have searched for solutions to this issue, but none of them seem to work for me. It appears that my case is somewhat unique.

In a previous project, simply running npm install jquery resolved the problem. Despite not having it listed in my package.json file and not explicitly requiring jquery in any of my files like shown here, everything functioned as expected.

However, in my current project, I have tried reinstalling jquery using npm, adding it to dependencies in package.json, and including it in my code:

$ = require('jquery'); Backbone.$ = $;

Unfortunately, none of these actions have solved the issue.

Has anyone else encountered this specific problem before? Any insights into what could be causing it?

Edit:

I compared the package.json of the working jquery module with the one in my broken app. Here are the differences:

Working version:

 "url": "https://github.com/jquery/jquery.git"
 "_from": "jquery@*"

Broken version:

 "url": "git+https://github.com/jquery/jquery.git"
 "_from": "jquery@>=2.1.0 <3.0.0"
 "readme": "ERROR: No README data found!"

If more detailed context is needed (such as line numbers or parent properties), please let me know. I wanted to simplify the comparison to see if anything stands out.

Edit 2:

Changing the "url" parameter did not make a difference. Substituting the "_from" value with the working version also had no effect.

At this point, I am questioning why the README data cannot be located. Both of my README files are identical, so I doubt this is the root cause of the problem.

Edit 3:

I eventually resolved the issue by removing the jquery module and directly including jquery.js in my index view. Although this solution works, it is not ideal.

I am still interested in understanding what was causing the initial problem. If anyone has any insights, I would appreciate hearing them.

Answer №1

For successful installation, try using npm install --save jquery. It seems like browserify is looking for the jquery module in the backbone location. Have you checked for any errors in your browserify-shim configuration in the package.json?

If the issue persists, consider using browserify-shim to specify the correct location for jquery by adding this to your package.json:

  "browserify": {
    "transform": [
      "browserify-shim"
    ]
  },
  "browser": {
    "jquery": "./node_modules/yet/old/jquery/location"
  }

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

Retrieving the class name using jQuery

In my HTML code, there is a div with three classes defined as: <div class = "a b c"> .. </div> My goal is to access only the class b using the .attr() method. Is this achievable? ...

Warning issued by npm during compilation: The template string expression is unexpected as there should be no curly braces in the

Getting an npm warning during compiling (Unexpected template string expression no-template-curly-in-string) import React from 'react'; const Card = ({name, email, id }) => { return ( <div className='tc bg-light-green dib b ...

What steps should I take to generate a stylized date input in javascript?

Looking to dynamically create a date string in JavaScript with the following format: dd-MMM-yyyy Need the dd part to change between 1 and 29 each time I generate the variable within a loop Month (MMM) should be set as Jan ...

Building on the functionality of AngularJS, a directive scope can be established to access and modify

Can a directive accept and utilize a parameter as its scope value? For instance: angular .module('app', []) .controller('CTRL', function($scope) { $scope.some_value = { instance1: { key1: 'value11', ...

Changing Marker Colors in OpenLayers After Importing GPX Data: A Quick Guide

Check out this link for a code tutorial on importing GPX files and displaying map markers. I successfully implemented this code to show map markers. Is there a way to customize the color of the markers? Edit: var fill = new Fill({ color: 'rgba(2 ...

Determine the length of the content within an HTML container that has

I am attempting to retrieve the length of the container's content in HTML dynamically. However, I am only receiving the object instead of the desired result. <script> $(document).ready(function (e) { var adsense_box_len = $(&apo ...

Experiencing issues with autoungrabify or autolock in cytoscape.js?

I have been working on a web application using Cytoscape.js, and I recently integrated the Edgehandles extension to allow users to add edges. The two types of edges that can be added are undirected and directed. Adding directed edges is functioning as expe ...

Dividing an array of characters within an ng-repeat and assigning each character to its individual input tag

Hello, I'm currently learning Angular and I have a unique challenge. I want to take the names in a table and break each name into individual <input> tags, so that when a user clicks on a letter, only that letter is selected in the input tag. For ...

Presenting quiz questions using javascript

Currently, I am following the learning path on javascriptissexy.com and facing a challenge with displaying quiz questions in the best way possible. As a beginner student of JavaScript, my question is about how to approach developing the behavior of a quiz ...

Guide to Including an Object in AngularJS Scope

I am completely new to Angular JS and mongod. My goal is to add a new ingredient field to this page for the specific drink that the + button is clicked on. Here is how my view looks like: UI Image This is what my .jade file contains: block content ...

Capture a snapshot of a webpage that includes an embedded iframe

Currently, we have a nodeJS/angular 4 website that contains an iframe from a third party (powerBI Emebdded). Our goal is to develop a feature that allows the end user to capture a screenshot of the entire page, including the content within the iframe. We ...

Upon refreshing the page, nested React routes may fail to display

When I navigate to the main routes and their nested routes, everything works fine. However, I encounter an issue specifically with the nested routes like /register. When I try to refresh the page, it comes up blank with no errors in the console. The main r ...

Extracting JavaScript variable data to PHP using Ajax technology

I've been trying to save latitude and longitude values in PHP variables, but I'm having trouble. Here is the code I'm using. Can anyone please help me figure out why these values are not being stored in PHP variables: Code: <!DOCTYPE h ...

Retrieving information from a Kendo grid cell

I am working on a web application that utilizes Kendo Grid. How can I retrieve the values of the "Ticket No" from the selected checkboxes? https://i.stack.imgur.com/aPOje.png This is my code: var grid = $("#poGrid").data("kendoGrid"); grid.items().filte ...

Calculate the combined sum of values within dynamic inputs that share a common class, and automatically update the sum whenever input values are altered or new rows are added or removed dynamically

$("#add-btn").click(function() { $("#dynamic").append('<tr>' + '<td class="td">' + '<input type="number" name="Debit" class="form-control Debit"/>' + '</td>' + '<td c ...

Using a combination of Ajax and jQuery in Rails4 to showcase a date in the %m/%d/%yyyy format ultimately results in a split

Recently, I encountered an issue with an ajax call that retrieves a date from the database. The date is stored as a double in the database and then converted to a string. I used Date.parse to change it into a date object and used strftime to format it. How ...

Clicking two times changes the background

I am facing an issue with three boxes on my website. Each box is associated with a corresponding div. When I click on any box, the div displays and the background color turns red. However, when I click on the same box again, the div disappears but the back ...

How can you retrieve the value of a CSS file in Javascript and CSS?

Imagine there is an element with the class .selector. This class defines its style. Once the page has finished loading, some JavaScript code is executed - the specifics are not important. What matters is that the CSS properties have set the object's ...

Rails failing to properly decode JSON from jQuery resulting in an array transforming into a hash with integer keys

Every time I try to send an array of JSON objects from jQuery to Rails using a POST request, I encounter the same issue. When I stringify the array, it seems that jQuery is handling it correctly: "shared_items"=>"[{\"entity_id\":\"253&bs ...

Having trouble locating the express module in your node application?

I am facing an issue that I can't seem to pinpoint the cause of, even though everything should be functioning properly. According to npm, I have express installed: C:\Users\phucker\Desktop>node init.js module.js:340 throw err; ...