Authenticating with npm nodejs bitcoin-core module
I tried the following, and it works:

const Client = require('bitcoin-core');

const client = new Client(
    {   
        username: 'yourUsernameHere',
        password: 'yourPasswordHere',
        port: '8332'
    }
);

client.getInfo().then((help) =&gt; console.log(help));