Linked Questions

10 votes
2 answers
30k views

I can't fixed a problem of "Uncaught SyntaxError: Cannot use import statement outside a module" [duplicate]

I have "three" files in one folder 1. index.html 2. index.js 3. helper.js I want to export code from helper.js and import code to index.js (I already link up index.js to index.html). I did like that ...
SA Noyon Ahmed's user avatar
0 votes
1 answer
4k views

VanillaJS - Why is import/export of this JS class not working? [duplicate]

I'm trying to import a JS class from the file "paddle.js" to be used in another file "game.js" (no JS libraries or frameworks used, just pure simple VanillaJS), and I can't seem to figure why this ...
singh.rbir's user avatar
0 votes
2 answers
585 views

Cannot use import statement outside a module-javascript [duplicate]

I'm a self-study student and having "Cannot use import statement outside a module-javascript" error So, im trying to import hello() from hello.js.. ///////////hello.js/////// export default function ...
Richard Piao's user avatar
0 votes
1 answer
738 views

Using ES6 modules in the browser [duplicate]

I am trying to export and import objects in the browser using ES6 modules. I have tried import { options } from 'options'; but I get the error Uncaught SyntaxError: Unexpected token import. Then I ...
Jamgreen's user avatar
  • 11.2k
0 votes
2 answers
398 views

How to use a class from one JS file in another JS file? [duplicate]

I'm trying to use a class from A.js file in B.js file, i made an instance of A.js class and tried to call its function in B.js, but i got an error saying Uncaught SyntaxError: Cannot use import ...
mario_meixner's user avatar
1 vote
1 answer
74 views

Javascript Reading class from Js file installed via npm [duplicate]

In my simple html + js project i have installed paper.js using npm install paper . But when i am trying to use a class new Point() , VS code is saying to convert it to E6 module . After click on the ...
Mohit H's user avatar
  • 959
44 votes
2 answers
24k views

Classic scripts vs. module scripts in JavaScript

I was going through the WHATWG specifications for async and defer attributes for the <script> tag, when I saw this statement: Classic scripts may specify defer or async; module scripts may ...
nikjohn's user avatar
  • 22.1k
4 votes
5 answers
31k views

Call JavaScript function from another JavaScript file

<html> <head> <script src="./first.js"></script> <script src="./second.js"></script> </head> </html> In the first.js file, ...
Ande Mohit's user avatar
9 votes
3 answers
21k views

"Uncaught SyntaxError: Unexpected token {" while importing

I am trying to import a function from another javascript file but an error occurs with the import statement in main.js. main.js: import {Event} from 'event.js'; let asdf = new Event("hi", "hi", "hi"...
Hyrial's user avatar
  • 1,898
0 votes
2 answers
3k views

ES6 Module throwing unexpected token error

I'm absolutely blown away that I'm having this issue, but here we go. I'm getting the error in the console: Uncaught SyntaxError: Unexpected token { On this line of code in my index.js file: import {...
Adam McGurk's user avatar
2 votes
1 answer
1k views

How to run moduled typescript output using regular script tag?

i'm not very familiar with the JavaScript ecosystem, so not exactly sure if my title is correct ... I wrote a simple application with pure ES6 with the help of lots of "googling", but i kept on ...
Jan Vladimir Mostert's user avatar
0 votes
1 answer
1k views

Unexpected token import : vue js with laravel

I have created laravel setup and trying to configure vue js. for that i wrote code in app.js file import Vue from 'vue'; import VueRouter from 'vue-router'; Vue.use(VueRouter); import VueAxios from ...
Hardika Satasiya's user avatar
3 votes
2 answers
689 views

How to get Javascript's IMPORT EXPORT working. Do I need transpiler?

I am so confused about this. All I want to do is simply break up my javascript into modules, and include them in certain pages. Some pages may need my user-module.js , some pages may not. I have ...
John S.'s user avatar
  • 514
0 votes
1 answer
583 views

vue plugin throws error Uncaught SyntaxError: Unexpected token {

I wanted to check out vue and use it for my next project. I wanted to use Hooper, a image carousel. I've installed it via npm install hooper. Now in my script file I use import { Hooper, Slide } ...
user avatar
0 votes
1 answer
371 views

Import/export implementation using Handlebars and Node.js/Express

I am trying to implement import/export using handlebars with nodejs/express. For some reason it gives me the following error Uncaught SyntaxError: Unexpected token { File - api.js import { ...
John John's user avatar
  • 1,500

15 30 50 per page