Skip to content

[Bug]: Running in ESM (*.mjs) returns "ERROR : use init before" #186

@SunboX

Description

@SunboX

Expected behavior

getting a wifi networks list

Current behavior

Error thrown: ERROR : use init before

Which are the affected features

  • node API
  • CLI

Which is your operating system?

Linux

Environment

OpenEmbedded / Yocto / Linux kernel 5.4.88 running on i.MX6X with ath6k and bcm43236b drivers

Version of node-wifi

2.0.16

Steps to Reproduce

app.mjs

import * as wifi from 'node-wifi'

export class App {

    static async start() {
        console.log(process.platform)

        wifi.init({
            debug: true,
            iface: null // network interface, choose a random wifi interface if set to null
        })

        wifi
            .scan()
            .then(networks => {
                console.log(networks)
            })
            .catch(e => {
                console.log(e)
            })
    }
}

App.start()
$ node app.mjs

linux
ERROR : use init before

Solutions

maybe related to

exports.scan = () => {
  throw new Error('ERROR : use init before');
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions