Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: SerialPort is not a constructor #2494

Open
CalRL opened this issue May 6, 2022 · 1 comment
Open

TypeError: SerialPort is not a constructor #2494

CalRL opened this issue May 6, 2022 · 1 comment

Comments

@CalRL
Copy link

CalRL commented May 6, 2022

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.

@reconbot
Copy link
Member

reconbot commented May 6, 2022

See our upgrade guide. You're using v9 apis

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants