Skip to content

TypeError: SerialPort is not a constructor #2433

@khunpoum

Description

@khunpoum

SerialPort Version

10.3.0

Node Version

12.22.10 and 16.14.0 - the same results

Electron Version

No response

Platform

Ubuntu 20.04.3 LTS (5.4.0-99-generic)

Architecture

x64

Hardware or chipset of serialport

No response

What steps will reproduce the bug?

code test.js

const SerialPort = require('serialport');
const port = new SerialPort({path: '/dev/ttyUSB0', baudRate: 9600});

npm install serialport
serialport@10.3.0 installed

ls /dev/ttyUSB*
/dev/ttyUSB0

What happens?

node test.js output:

const port = new SerialPort({path: '/dev/ttyUSB0', baudRate: 9600});
             ^

TypeError: SerialPort is not a constructor
    at Object.<anonymous> (/root/watchtemp/test-sp.js:2:14)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47

What should have happened?

there should be no errors

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions