How to import jQuery from a file using es6

distante

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.

F_Mekk

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to import jquery using ES6 syntax?

How to import everything from a module in react using es6?

Cannot import router from file with ES6 import/export?

How do I import jQuery Masonry using ES6 modules?

In typescript, how can I import a plain javascript file with a default export using es6 syntax?

{Solved} ES6 How to import fresh array from a .js file (exported array)

Using jQuery with classes from ES6

How to import a JS file in another JS file in ES6?

Using Jquery and Bootstrap with Es6 Import for React App

Is it possible to import a .css file using ES6 modules?

How do I create a main import file in ES6?

ES6 - how to test Jasime tests thru karma using ES6 like 'import' statement

How to import class using ES6 syntax? (without Babel)

How to import and export components using React + ES6 + webpack?

How to import .html fragment using es6 syntax in TypeScript

How to import pg-promise using ES6 syntax?

How to import both default and named from ES6 module?

How to import both default and named from an ES6 module

How does 'require' operates differently from 'import' es6?

How to get the element from a jQuery on() event using an ES6 arrow function?

How to import in ES6?

Utilise jQuery plugin with ES6 import

How to replace CDN import with ES6 import from NPM packages?

How do I import a jQuery plugin via webpack and put it under $/jQuery? (ES6 + TypeScript)

Import JavaScript file and call functions using webpack, ES6, ReactJS

ES6 import from root

ES6: import module from URL

ES6 `export * from import`?

ES6 - Convert from 'require' to 'import'