Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running @hapi/hapi giving error "#meetings = null SyntaxError: Invalid or unexpected token"

Was using

@hapi/hapi : ^20.0.0

node.js : v10.19.0

Got the following error stack

|     #meetings = null;
|     ^
| 
| SyntaxError: Invalid or unexpected token
|     at Module._compile (internal/modules/cjs/loader.js:723:23)
|     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
|     at Module.load (internal/modules/cjs/loader.js:653:32)
|     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
|     at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Was using the following code

'use strict';

const Hapi = require('@hapi/hapi');

const init = async () => {

    const server = Hapi.server({
        port: 5000,
        host: 'localhost'
    });

    await server.start();
    console.log('Server running on %s', server.info.uri);
};

process.on('unhandledRejection', (err) => {

    console.log(err);
    process.exit(1);
});

init();
like image 492
Rishikesh Chandra Avatar asked Sep 04 '20 21:09

Rishikesh Chandra


2 Answers

You should upgrade the Node version to 12+ which supports private class fields like #meetings.


References: Table of Compatibility

like image 161
Kostas Minaidis Avatar answered Nov 17 '22 23:11

Kostas Minaidis


Upgraded node version from v10.19.0 to v12.18.3 and it worked

Got the reference from https://github.com/outmoded/sntp/issues/37

like image 33
Rishikesh Chandra Avatar answered Nov 17 '22 22:11

Rishikesh Chandra