-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module "jquery" #679
Comments
Can you provide a project reproducing this? |
It should be easy to reproduce. Use: Then add the package: Now import it: Note: I'm using jQuery 1.9.1 |
With import 'jquery/jquery';
// now you can use window.$ With import $ from 'jquery';
// now you can use $ |
|
Hi @gaearon, I have tried this: import $ from 'jquery';
window.jQuery = window.$ = $; Package Versions: "bootstrap": "^3.3.7",
"jquery": "3.1.0", I have set up a test repo where I have reproduced this. |
Do you need to use Bootstrap itself? I would recommend React Bootstrap instead. It is compatible with Bootstrap CSS but implements JS part as React components. |
Thanks for the reply @gaearon In this case I think I really need to since I am porting some plain HTML to React. Using React bootstrap would take much much longer. |
Anyway, I sent a fix here: kevgathuku/react-bootstrap-jquery#1. But I would recommend using React Bootstrap over Bootstrap itself. Since React takes care of DOM manipulation, it is often much more convenient to use React components than something like Bootstrap, although you could mix them if you want to. |
I hope this helps! |
Worked like a charm. Thanks 😄 I'll probably port it to React bootstrap later on, but I needed to get over the barrier of having something to work with first, before I can improve it. Thanks a lot for taking your time to help @gaearon. Really appreciate it 👍 |
No worries, if you have any problems please file issues! We’re happy to help. |
Btw, React Bootstrap does not currently support Bootstrap 4 |
The reason is that you need to provide the plugin ("$" and/or the "jQuery") to webpack config. You'll have to eject though. I'm not sure if the argument about using React Bootstrap is universal because people may want to use it for the javascript animations, or for very custom stuff, or even using Bootstrap 4.
|
You don’t need to. That’s one possible way of doing it, but my fix here is completely equivalent: https://github.com/kevgathuku/react-bootstrap-jquery/pull/1/files. |
reactstrap provides React components for Bootstrap 4 |
if anyone uses jquery 3.x , |
btter use bootstrap |
I am porting over some old code that uses jQuery. For now, I need jQuery in my project (will slowly get rid of it). I added it to my
dependencies
in package.json and rannpm install
. I seejquery
undernode_modules
now.In my component file, when I add
import $ from 'jquery';
, I see this error:I referred to #614 but still no luck.
The text was updated successfully, but these errors were encountered: