Pierce01 / MinecraftLauncher-core

Lightweight module that downloads and runs Minecraft using javascript / NodeJS
MIT License
359 stars 82 forks source link

Unexpected Token.. Error Occurred #57

Closed Nishant1500 closed 3 years ago

Nishant1500 commented 3 years ago

function launch() {
    const { Authenticator, Client} = require("minecraft-launcher-core");
const launcher = new Client();
const user = document.getElementById('username')
const pass = document.getElementById('password')

let opts = {
    overrides: {
        gameDirectory: "", // where the game process generates folders like saves and resource packs.
        minecraftJar: "",
        versionJson: "",
        directory: "", // where the Minecraft jar and version json are located.
        natives: "", // native directory path.
        assetRoot: "",
        libraryRoot: "",
        cwd: "", // working directory of the java process.
        detached: true, // whether or not the client is detached from the parent / launcher.
        classes: [], // all class paths are required if you use this.
        minArgs: 11, // The amount of launch arguments specified in the version file before it adds the default again
        maxSockets: 2, // max sockets for downloadAsync.
        // The following is for launcher developers located in countries that have the Minecraft and Forge resource servers
        // blocked for what ever reason. They obviously need to mirror the formatting of the original JSONs / file structures.
        url: {
            meta: "https://launchermeta.mojang.com", // List of versions.
            resource: "https://resources.download.minecraft.net", // Minecraft resources.
            mavenForge: "http://files.minecraftforge.net/maven/", // Forge resources.
            defaultRepoForge: "https://libraries.minecraft.net/", // for Forge only, you need to redefine the library url
                                                                 // in the version json.
            fallbackMaven: "https://search.maven.org/remotecontent?filepath="
        }
    }
 }

launcher.launch(opts)

launcher.on('debug', (e) => console.log(e));
launcher.on('data', (e) => console.log(e));
}

This IS My Code Down Is The Error Code


Uncaught SyntaxError: Unexpected token ...
    at createScript (vm.js:74)
    at Object.runInThisContext (vm.js:116)
    at Module._compile (module.js:533)
    at Object.Module._extensions..js (module.js:580)
    at Module.load (module.js:503)
    at tryModuleLoad (module.js:466)
    at Function.Module._load (module.js:458)
    at Module.require (module.js:513)
    at require (internal/module.js:11)
    at Object.<anonymous> (C:\Users\Nishant\Downloads\Electron App\node_modules\minecraft-launcher-core\index.js:2)
Pierce01 commented 3 years ago

By using empty overrides you are essentially giving MCLC nothing to work with. Please read the documentation and follow the provided example.

Pierce01 commented 3 years ago

Adding on, don't use overrides. Just follow the standard example.

Nishant1500 commented 3 years ago

Ok I used the standard example still its coming unexpected token ... Can You Help Me Please : D

Pierce01 commented 3 years ago

Feel free to post what you have.

Nishant1500 commented 3 years ago
const { Client, Authenticator } = require('minecraft-launcher-core');
const launcher = new Client();
const account = require('./account.json);

let opts = {
    clientPackage: null,
    // For production launchers, I recommend not passing 
    // the getAuth function through the authorization field and instead
    // handling authentication outside before you initialize
    // MCLC so you can handle auth based errors and validation!
    authorization: Authenticator.getAuth(account.username),
    root: "./minecraft",
    version: {
        number: "1.16.1",
        type: "release"
    },
    memory: {
        max: 1024",
        min: "1024"
    }
}

launcher.launch(opts);

launcher.on('debug', (e) => console.log(e));
launcher.on('data', (e) => console.log(e));

I am getting this :/

Uncaught SyntaxError: Unexpected token ...
    at createScript (vm.js:74)
    at Object.runInThisContext (vm.js:116)
    at Module._compile (module.js:533)
    at Object.Module._extensions..js (module.js:580)
    at Module.load (module.js:503)
    at tryModuleLoad (module.js:466)
    at Function.Module._load (module.js:458)
    at Module.require (module.js:513)
    at require (internal/module.js:11)
    at Object.<anonymous> (C:\Users\Nishant\Downloads\Electron App\node_modules\minecraft-launcher-core\index.js:2)
Pierce01 commented 3 years ago
const account = require('./account.json);

Is not proper sytanx, you're missing another '.

Nishant1500 commented 3 years ago

Ok I did it but still getting it :/ The problem is in ...this.options.overide in launcher.js

MuhammadUsmanMithani commented 3 years ago
const account = require('./account.json);

Is not proper sytanx, you're missing another '.

ye but actually in our launcher the syntax is correcty(me and @Nishant1500 are making the launcher together), and according to him it still doesnt work, but im getting a diff output

Pierce01 commented 3 years ago

Your stack trace does not reflect this. It would be easier to continue our convo in the Discord, not sure why you switched over to here

Nishant1500 commented 3 years ago
const account = require('./account.json);

Is not proper sytanx, you're missing another '.

ye but actually in our launcher the syntax is correcty(me and @Nishant1500 are making the launcher together), and according to him it still doesnt work, but im getting a diff output

Umm can u show me ur error ??

MuhammadUsmanMithani commented 3 years ago

see discord

Nishant1500 commented 3 years ago

My all things work perfectly expect the launcher syntax error

Nishant1500 commented 3 years ago

Fixed myself :> It Will Be Great If You Delete This Issue :)