#StackBounty: #javascript #wordpress #woocommerce #unpkg SyntaxError: import not found: default when defining a js class

Bounty: 50

I’m building a WordPress plugin. I have the following in a JavaScript file called demo-one.js:

import WooCommerceRestApi from "https://unpkg.com/@woocommerce/woocommerce-rest-api@1.0.1/index.js";


class someClass {
    constructor() {
        alert("Hello again!");

export default function(){
    var mySomeClass = new someClass();

… and I find that in my console, I get the following error:

SyntaxError: import not found: default | demo-one.js:1:7

All the information on the export keyword that I could find online used free-floating values and functions, outside of a class, so I apologize for flying a bit blind.

I was pretty sure that I was correctly defining a default export, but it appears that I’m not. What am I doing wrong here?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.