Sign in to follow this  

es6 classes

Recommended Posts

So, I've created simple class called Event inside my resources and I've made new instance of this class inside server-side entrypoint. After executing server.exe I have a lot of errors inside console.

Source code:

export class Event {
    constructor(name, callback) { = name;
        this.callback = callback;

const Event = require( './modules/event/Event.js');

const testEvent = new Event("test", function() {});


Error: E:\gry\RAGEMP\lsonline\server-files\packages\LSOnline\modules\event\Event.js:3
export class Event {

SyntaxError: Unexpected token export
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:152:10)
    at Module._compile (module.js:605:28)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (E:\gry\RAGEMP\lsonline\server-files\packages\LSOnline\index.js:6:15)


I've tried to use import instead of require but it didn't help me. Can somebody write me something small and simple tutorial how to implement class? Maybe I've made some simple mistake and I can't find it. Thanks for helping me.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.