I'm trying to import jQuery using ES6, and, most importantly, I'm running the code using babel-node (cli).
I've read a question, but the solution reported there doesn't seem to work: I tried
npm i --save jquery
and then
import {$,jQuery} from 'jquery';
console.log($);
But I get undefined logged to the console, and I cannot use jQuery.
How should I import $?
I also tried
import $ from 'jquery';
as suggested from @Jai and reported on the npm manual, but even though I obtain "[Function"] as the result of console.log($), $.getJSON("www.google.com") returns me TypeError: _jquery2.default.getJSON is not a function.
This is true only running the code from babel-node (cli), if I run the code from the browser loading the generated bundle it works.
import * as $ from 'jquery';If you writeimport { $, JQuery }, you try to destructure the object the jquery file returns, which isn't correct I think. Also, $ and JQuery are the same function.