Due to this project idiosyncrasies I need to import jQuery
into my main.js
using a direct path that is not in the node_modules folder but I am not able to do it. All the questions I have found points to jquery
that lives in node_modules
I have this
import {MyModule} from './components/myModule.js';
import jQuery from './jquery/jquery-3.3.1.js';
MyModule
works as expected (on Chrome) but jQuery yields:
Uncaught SyntaxError: The requested module does not provide an export named 'default'
jquery-3.3.1.js is the uncompressed, development jQuery 3.3.1 version from jQuery.com, I have also tried with the production version.
How should I import it?
Edit:
This is NOT a duplicate of How to import jquery using ES6 syntax?. Because import {$,jQuery} from 'jquery';
searches on node_modules
and when I import it from the given path I get the error quoted above.
You should use:
import * as jQuery from './jquery/jquery-3.3.1.js'
Documentation about the import statement: https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Instructions/import
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