We have upgraded the community system as part of the upgrade a password reset is required for all users before login in.

Nodejs Error "SerialPort is not a function...." with node-serialport-omega2

  • Re: Serial port communication using Node.js

    @Steven-de-Salas Hello I am having some trouble getting the node-serialport-omega2 module to function.

    To isolate the problem I have factory reset my Omega and only installed Nodejs and NPM.

    I downloaded the node_modules from the above link


    and SCP'd those files to the Omega.

    Then checked it with npm ls, which reports several missing dependencies. I installed all depenencies until npm ls reports no errors ( Except for a version conflict with debug, however the error states that the serialport module will still load. )

    I have a very minimal script.

    var SerialPort = require('serialport');
    var port = new SerialPort('/dev/ttyS0',
                            parser: SerialPort.parsers.readline('\n'),
                            baudRate: 115200

    when I run the script I get the following error.

    var port = new SerialPort('/dev/ttyS0',
    TypeError: SerialPort is not a function

    If it will be of interest or help I can post my full npm ls here.

    Thank you in advance for your help.

  • Hi @Jeff-Seese,

    Please note that the SerialPort API has changed between versions.

    The one on node-serialport-omega2 is version 3. Which is why it might get a bit confusing if you look at the latest docs from the original serialport repo instead of the omega2 fork of the same.

    Please refer to the docs on the omega2 fork. They should work as expected.

    var SerialPort = require('serialport'); // original fork (v5)
    var port = new SerialPort('COM1');
    var SerialPort = require('serialport').SerialPort; // omega2 port (at v3)
    var port = new SerialPort('COM1'); 

  • buenas tardes, tengo el mismo problema "serialport is not a function pero con el arduino uno, alguien me puede decir por favor qué hago? soy nueva y la verdad estoy muy perdida. gracias

  • @amanda Este foro es para soporte de dispositivos Onion Omega2, no para productos Arduino. ¿Está utilizando un dispositivo Omega2? Si es así, describa su configuración.

Looks like your connection to Community was lost, please wait while we try to reconnect.