I am trying to bundle up my app with browserify and am getting this error:Cannot find module 'jquery' from '/home/test/node_modules/backbone'
Now questions of this nature have been asked before, but the solutions haven't helped me. Perhaps I have somewhat of a unique case.
In another app, running npm install jquery
fixed it. I didn't have it in my package.json
and I wasn't requiring jquery
in any of my files like what's done here. Everything worked.
In this new app, it doesn't. I tried reinstalling jquery with npm. Nothing. Added it to my dependencies in package.json
. Nothing. Included it in my code:
$ = require('jquery'); Backbone.$ = $;
Nothing.
Does anyone have experience with this? What could be going wrong?
Edit:
Diff'd the package.json
of the jquery module in the working app and the current one.
Working one:
"url": "https://github.com/jquery/jquery.git"
"_from": "jquery@*"
Broken one:
"url": "git+https://github.com/jquery/jquery.git"
"_from": "jquery@>=2.1.0 <3.0.0"
"readme": "ERROR: No README data found!"
If you want more context (line numbers, parent property, and such), I'd be happy to provide that. I just wanted to simplify it - maybe something stands out.
Edit 2:
Changing the "url"
param shouldn't changed anything. Replacing the "_from"
with the one that works didn't change anything.
Now, I'm wondering why README data
is not found. My README files are the same. Granted, I highly doubt that this is the source of the problem.
Edit 3:
My solution was to remove the jquery module and just include jquery.js in my index view. I'm not particularly happy with this, but it works.
I would still like an answer though; curious what was wrong before.
This should work well with npm install --save jquery
. Seems that browserify
searches for jquery
module in backbone
location. Can you find out why is this so ? Don't you have some browserify-shim
configuration errors in your package.json
?
If you still have problem you can use browserify-shim
to point browserify
to proper location by putting this in package.json
"browserify": {
"transform": [
"browserify-shim"
]
},
"browser": {
"jquery": "./node_modules/yet/old/jquery/location"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With