The way you import serialport changed in version >= 10:

Below you have two equivalent examples to import serialport module.

Solution #1

var sp = require('serialport')

sp.SerialPort.list()
.then((data) => console.log(data))
.catch(err => console.log(err));

Solution #2

const {SerialPort} = require('serialport')

SerialPort.list()
.then((data) => console.log(data))
.catch(err => console.log(err));

For reference, it's stated here: https://serialport.io/docs/guide-upgrade#exports

Answer from Lothre1 on Stack Overflow
🌐
GitHub
github.com › rwaldron › johnny-five › issues › 1789
TypeError: serialport.list is not a function (board.js line 42) · Issue #1789 · rwaldron/johnny-five
June 16, 2022 - serialport.list().then(results => { const portPaths = results.reduce((accum, result) => { ... Sign up for free to join this conversation on GitHub. Already have an account?
Author   rwaldron
Discussions

[ISSUE] SerialPort.list is not a function
I reinstalled particle-cli in an ... using npm install -g particle-cli I get output, but none of the serial commands work: they all output SerialPort.list is not a function. I uninstalled and reinstalled through every path mentioned here ...... More on community.particle.io
🌐 community.particle.io
0
0
March 3, 2022
SerialPort has no method 'list'
I have a very simple script to just the available serial ports and then connect to one, write a char and put the response on the console. CODE HERE In my scripts directory I did: #npm install More on stackoverflow.com
🌐 stackoverflow.com
November 22, 2021
[Solved] serialport.list() is returning 'not a function' error with node.js
Helpless Asks: serialport.list() is returning 'not a function' error with node.js I have been trying to use Node SerialPort to check the ports list using javascript, and when I attempt to run... More on solveforum.com
🌐 solveforum.com
0
0
September 9, 2022
UnhandledPromise Warning, SerialPort.list, no callback, return promise...
Hello, I'm new at JS, and Node, my goal is finally to provide an available Portlist to a combobox. But I'm already tumbling with below Code which does not work, and gives always follow erro... More on github.com
🌐 github.com
5
October 31, 2019
🌐
GitHub
github.com › serialport › node-serialport › issues › 2567
SerialPort.list is not a function · Issue #2567 · serialport/node-serialport
November 27, 2022 - board.js:42 Uncaught TypeError: serialport.list is not a function at Board.detect (board.js:42) at new Board (board.js:291) at addBoard (HardwareDevicesService.ts:24) run without errors · I'm using electron-forge but I dont think that matters. No one assigned ·
Author   serialport
🌐
Particle
community.particle.io › developer tools › cli
[ISSUE] SerialPort.list is not a function - CLI - Particle
March 3, 2022 - I reinstalled particle-cli in an ... using npm install -g particle-cli I get output, but none of the serial commands work: they all output SerialPort.list is not a function. I uninstalled and reinstalled through every path mentioned here ......
🌐
Devcodef1
devcodef1.com › news › 1010415 › fixing-serialport-list-is-not-a-function-error-with-johnny-five-and-arduino-board
Encountering 'serialport.list is not a function' error with Johnny Five and Arduino board
June 2, 2023 - The 'serialport.list is not a function' error is typically caused by a mismatch between the version of the serialport library and the version of Johnny Five.
🌐
GitHub
github.com › serialport › node-serialport › issues › 1977
UnhandledPromise Warning, SerialPort.list, no callback, return promise... · Issue #1977 · serialport/node-serialport
October 31, 2019 - Hello, I'm new at JS, and Node, my goal is finally to provide an available Portlist to a combobox. But I'm already tumbling with below Code which does not work, and gives always follow error: "UnhandledPromise...Warning:.... SerialPort.list no longer takes a callback.... only return a promise". Unfortunately I have no idea, why this code should not work :-( ? var SerialPort = require('serialport'); // callback approach SerialPort.list(function (err, ports) { ports.forEach(function(port) { console.log(port.comName); console.log(port.pnpId); console.log(port.manufacturer); }); }); thanks ·
Author   serialport
🌐
Tabnine
tabnine.com › home › code library
How to use list function in SerialPort
July 25, 2024 - The Tabnine Code Library is no longer available — but you can still get the answers and suggestions you need from our AI code assistant.
Find elsewhere
🌐
Onion
community.onion.io › home › omega talk › nodejs error "serialport is not a function...." with node-serialport-omega2
Nodejs Error "SerialPort is not a function...." with node-serialport-omega2 | Community
February 25, 2022 - 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');
🌐
npm
npmjs.com › package › @serialport › list
serialport/list
December 24, 2024 - See our api docs https://serialport.io/docs/bin-list. Latest version: 13.0.0, last published: 8 months ago. Start using @serialport/list in your project by running `npm i @serialport/list`. There are 7 other projects in the npm registry using @serialport/list.
      » npm install @serialport/list
    
Published   Dec 24, 2024
Version   13.0.0
🌐
iobroker
forum.iobroker.net › iobroker community home › deutsch › error/bug › mysensors adapter findet keinen serialport mehr
MySensors Adapter findet keinen Serialport mehr
August 29, 2022 - also nach viel rumprobieren habe ich festgestellt, dass wenn die Instanz gestoppt wird, das Serialport Feld welches bei laufender Instanz ein Dropdown Menü hat, dieses durch ein Textfeld ersetzt wird. Dort habe ich den Serialport händisch eingetragen "/dev/ttyUSBx" nun hat er den Port geöffnet... und es scheint zu laufen. Ich weiß nicht ob es so gedacht ist, aber es funktioniert.
🌐
Npmdoc
npmdoc.github.io › node-npmdoc-serialport › build › apidoc.html
Node.js package to access serial ports. Welcome your ...
... port.on('open', function() { // open logic }); ``` ### Listing Ports `.list(callback)` Retrieves a list of available serial ports with metadata. * `callback` is a required function that looks should look like: `function (err, ports) { ... }`. `ports` will be an array of objects with port info. Only the `comName` is guaranteed, all the other fields undefined if unavailable. The `comName` is either the path or identifier (eg `COM1`) used to open the serialport.
🌐
Csdn
ask.csdn.net › questions › 7664180
serialport.list is not a function-有问必答-CSDN问答
屲亣猿猿的博客 TypeError: Object(...) is not a function · Node.js 串口读写包 node-serialport 2018-08-06 20:17
🌐
Serialport
serialport.io › upgrade guide
Upgrade Guide | Node SerialPort
Node SerialPort is now a duplex stream and can be paused and resumed on all platforms. ... SerialPort.list now has more consistent output across all platforms. This means the data in the objects may be different than 4x. Notably the path on OSX now returns the tty instead of the cu path and the 0x has been removed from values on linux and osx.
🌐
GitHub
github.com › serialport › node-serialport › issues › 276
Object is not a function · Issue #276 · serialport/node-serialport
var SerialPort = require("serialport"); var arduino = new SerialPort("/dev/ttyACM0", { baudRate : 9600, dataBits : 8, parity : 'none', stopBits: 1, flowControl : false, }); arduino.on("open", function () { console.log('open'); arduino.on('data', function(data) { console.log('data received: ' + data); }); }); ... /home/pi/NodeJs_Tests/NodeJS_Serial_Test_with_Arduino.js:2 var arduino = new SerialPort("/dev/ttyACM0", { ^ TypeError: object is not a function at Object.<anonymous> (/home/pi/NodeJs_Tests/NodeJS_Serial_Test_with_Arduino.js:2:15) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:902:3
Author   serialport
🌐
GitHub
github.com › serialport › node-serialport › issues › 2092
Error SerialPort.list no longer takes a callback and only returns a promise · Issue #2092 · serialport/node-serialport
June 2, 2020 - Help plz! error: (node:7599) UnhandledPromiseRejectionWarning: TypeError: SerialPort.list no longer takes a callback and only returns a promise at Function.SerialPort.list (/root/arduino/Paintduino...
Author   serialport
🌐
solveForum
solveforum.com › home › forums › solveforum all topics › tech forum
[Solved] serialport.list() is returning 'not a function&#039...
September 9, 2022 - 'use strict'; var serialport = require('serialport'); serialport.list(function (err, ports) { ports.forEach(function(port) { console.log(port.comName); console.log(' - pnpId: ' + port.pnpId); console.log(' - manufacturer: ' + port.manufacturer); console.log(' - serialNumber: ' + port.serialNumber); console.log(' - vendorId: ' + port.vendorId); console.log(' - productId: ' + port.productId); }); }); SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users.