SyntaxError: Cannot use import statement outside a module

Unfortunately is not going to be so easy in my case I guess… :frowning:

---------------------------- Option 1 ----------------------------
Regarding your first option, I’ve tried to do it but I couldn’t. I don’t have (or I don’t know how to get access to) package.json.

The following error is what I get when trying to add the package.json to the volume in docker via:

      - ./parse-server/package.json:/parse-server/package.json

And this is the error that I get when running docker afterwords.

    ERROR: for 043a399a1ce9_docker_server_1 Cannot start service server: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "PRJ_PATH/docker/parse-server/package.json" to rootfs at "/parse-server/package.json": mount PRJ_PATH/docker/parse-server/package.json:/parse-server/package.json (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

    ERROR: for server Cannot start service server: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "PRJ_PATH/docker/parse-server/package.json" to rootfs at "/parse-server/package.json": mount PRJ_PATH/docker/parse-server/package.json:/parse-server/package.json (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type ERROR: Encountered errors while bringing up the project.

Also, I’ve found that the package.json is also read-only and I can not edit it in any way that I know of. Or am I missing something?

---------------------------- Option 2 ----------------------------
I’ve try to use this:

const {createClassIfNotExists} = require("./generate_classes");

createClassIfNotExists('SomeClassV10').then(r => console.log(r));

and my generate_classes looks like this:

export const createClassIfNotExists = async (name) => {
    const schema = new Parse.Schema(name);
    schema.get().then(() => {
        console.log('Class exists!');
    }).catch(async (error) => {
        schema.addString('name', {required: true});
        schema.addNumber('age', {required: true});
        await schema.save();
        console.log('Class ' + name + ' was created');
    });
}

I’ve also try to change it like this:

async function createClassIfNotExists(name) {
    const schema = new Parse.Schema(name);
    schema.get().then(() => {
        console.log('Class exists!');
    }).catch(async (error) => {
        schema.addString('name', {required: true});
        schema.addNumber('age', {required: true});
        await schema.save();
        console.log('Class ' + name + ' was created');
    });
}

In both cases I am getting the following error:

SyntaxError: Unexpected token 'export'

---------------------------- Option 3 ----------------------------
And the last option which you suggest I am getting errors from the function itself like this:

 const function = await import {createClassIfNotExists} from "./generate_classes";
       ^^^^^^^^
 SyntaxError: Unexpected token 'function'

Am I missing something or I did my docker environment wrong?