index.js
import {$,jQuery} from 'jquery'; // export for others scripts to use window.$ = $; window.jQuery = jQuery;
First, as @nem suggested in comment, the import should be done from node_modules/
:
Well, importing from
dist/
doesn’t make sense since that is your distribution folder with production ready app. Building your app should take what’s insidenode_modules/
and add it to thedist/
folder, jQuery included.
Next, the glob –* as
– is wrong as I know what object I’m importing (e.g. jQuery
and $
), so a straigforward import statement will work.
Last you need to expose it to other scripts using the window.$ = $
.
Then, I import as both $
and jQuery
to cover all usages, browserify
remove import duplication, so no overhead here! ^o^y
Related Posts:
- SyntaxError: ‘import’ and ‘export’ may appear only with ‘sourceType: module’ – Gulp
- How to change CSS using jQuery?
- How to properly use jsPDF library
- Uncaught ReferenceError: $ is not defined?
- jQuery document.createElement equivalent?
- Toggle show/hide on click with jQuery
- Pure JavaScript equivalent of jQuery’s $.ready() – how to call a function when the page/DOM is ready for it [duplicate]
- jQuery .on(‘change’, function() {} not triggering for dynamically created inputs
- How to create a jQuery function (a new jQuery method or plugin)?
- Failed to load resource: the server responded with a status of 500 (Internal Server Error) in Bind function
- Scroll to an element with jQuery
- How can I scroll to an element using jQuery?
- jQuery Get Selected Option From Dropdown
- What does jQuery.fn mean?
- Node.js – SyntaxError: Unexpected token import
- Setting “checked” for a checkbox with jQuery
- Jquery : Refresh/Reload the page on clicking a button
- forEach is not a function error with JavaScript array
- How can I determine if a variable is ‘undefined’ or ‘null’?
- Cannot find module ‘@angular-devkit/core’
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- Set timeout for ajax (jQuery)
- jQuery Ajax File Upload
- How can I upload files asynchronously with jQuery?
- How can I quickly retrieve a value from a MapIterator returned from Object.keys function?
- How do I format date in jQuery datetimepicker?
- How to use npm jquery module?
- How to move an element into another element?
- document.getElementByID is not a function
- Moment js date time comparison
- How to create a JQuery Clock / Timer
- bootstrap-datetimepicker for bootstrap 4
- Proper way to wait for one function to finish before continuing?
- Access Control Request Headers, is added to header in AJAX request with jQuery
- Cannot read property ‘bind’ of undefined. React.js
- How to set ‘X-Frame-Options’ on iframe?
- How do I get an element to scroll into view, using jQuery?
- explode string in jquery
- Play an audio file using jQuery when a button is clicked
- How can I get the last character in a string?
- document.getElementsByClassName().innerHTML always returns “undefined”
- Jquery button click() function is not working
- jQuery: Check if div with certain class name exists
- How to define Global Arrays?
- Disable Chrome strict MIME type checking
- How to uncheck a radio button?
- Phone mask with jQuery and Masked Input Plugin
- JQuery get all elements by class name
- Attaching ‘onclick’ event to D3 chart background
- How do I check whether a checkbox is checked in jQuery?
- The preferred way of creating a new element with jQuery
- What is jQuery Unobtrusive Validation?
- jQuery count child elements
- CreateElement with id?
- How do I check if an element is hidden in jQuery?
- Set value of hidden input with jquery
- Creating a div element in jQuery
- jQuery equivalent of querySelector
- Convert normal date to unix timestamp
- jQuery replace one class with another
- Clearing my form inputs after submission
- Changing the image source using jQuery
- Get class list for element with jQuery
- Reload an iframe with jQuery
- Convert array to JSON
- How to disable scrolling temporarily?
- How to manage a redirect request after a jQuery Ajax call
- How do you remove all the options of a select box and then add one option and select it with jQuery?
- Add and remove multiple classes in jQuery
- Get the Highlighted/Selected text
- How to get the children of the $(this) selector?
- jQuery: Get selected element tag name
- Does ECMAScript 6 have a convention for abstract classes?
- window.onload vs $(document).ready()
- Why is jquery show() not working in example
- How can I use jQuery to run MySQL queries?
- jQuery scrollTop() method not working
- FormData append not working
- Uncaught TypeError: Cannot read property ‘toLowerCase’ of undefined
- How can JavaScript save to a local file?
- How to go to a URL using jQuery?
- How to close a window using jQuery
- How to find if div with specific id exists in jQuery?
- TypeError: $ is not a function WordPress
- Fully responsive HTML5 video
- HTML anchor link – href and onclick both?
- How can I know which radio button is selected via jQuery?
- jquery toggleClass not working
- JQuery Number Formatting
- How to add jQuery in JS file
- Get query string parameters url values with jQuery / Javascript (querystring)
- jQuery .animate() not working
- Adding JavaScript to a WordPress website
- AJAX not Working with php as supposed
- Cannot use characters ” in jQuery script in WordPress
- Can’t get rid of JQMIGRATE: Migrate is installed, version 3.3.2. Manually updated all the libralies and site. 5.8.2
- internal anchor links no longer working after upgrade
- Error on clicking ‘Screen Options’ tab only at Products-related editor screen(s) and for specific user
- Select parent from child class name then add another class name to the parent
- Access jQuery tabs from primary menu while adding/removing class on tab container elements (accessing diff. tabs/tab content via primary menu items)