node-serialport icon indicating copy to clipboard operation
node-serialport copied to clipboard

TypeError: SerialPort is not a constructor

Open CalRL opened this issue 3 years ago • 1 comments

SerialPort Version

10.4.0

Node Version

16.14.2

Electron Version

No response

Platform

Win10

Architecture

x64

Hardware or chipset of serialport

No response

What steps will reproduce the bug?

const express = require('express'); const app = express(); const chalk = require('Chalk'); const SerialPort = require("serialport"); const SerialPortStream = require ('@serialport/stream');

const port = 3000;

const arduinoCOMPort = "COM3";

const arduinoSerialPort = new SerialPort(arduinoCOMPort, { baudrate: 9600 });

arduinoSerialPort.on('open', function() { console.log(chalk.white("[") + chalk.green('+') + chalk.white("]") + 'Serial Port') })

What happens?

C:\Users\callum.burns\Documents\GitHub\projet-Panneau-Solaire\calcul\master.ts:11 ^

TypeError: SerialPort is not a constructor at Object. (C:\Users\callum.burns\Documents\GitHub\projet-Panneau-Solaire\calcul\master.ts:11:27) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47

NOTE: does not work in either .js or .ts files.

What should have happened?

Should have made the constructor

Additional information

NOTE: does not work in either .js or .ts files.

CalRL avatar May 06 '22 13:05 CalRL

See our upgrade guide. You're using v9 apis

https://serialport.io/docs/guide-upgrade

reconbot avatar May 06 '22 14:05 reconbot