while experimenting with deno to get readings from arduino, i got stuck on proper usage of serialport lib. i tried the following:
according to an article packages from pika.dev can be used.
but from pika i get:
However, no web-optimized "module" entrypoint was found in its package.json manifest.
also using jpsm.org didn't work either:
import * as SerialPort from "https://dev.jspm.io/serialport";
breaks with:
error: Uncaught TypeError: exists is not a function
probably because of the missing type headers that should be available with npm as @types/serialport
but not available on pika.dev or jspm.io.
using npm to install serialport
and @types/serialport
and referring to their local path as following, wasn't the solution either:
// @deno-types="./node_modules/@types/serialport/index.d.ts"
import * as SerialPort from "https://dev.jspm.io/serialport";
the error is:
error: relative import path "stream" not prefixed with / or ./ or ../ Imported from "file:///home/user/code/deno-serial-test/node_modules/@types/serialport/index.d.ts"
meaning it complains because the npm downloaded library dependencies aren't relative paths. this would mean i would need to change/patch all library modules.
the code i'm trying to run is:
// import * as SerialPort from "https://dev.jspm.io/npm:serialport@9.0.0/lib/index.dew.js";
// @deno-types="./node_modules/@types/serialport/index.d.ts"
import * as SerialPort from "https://dev.jspm.io/serialport";
async function readAvailablePorts() {
const ports = await SerialPort.list();
console.log('Available SerialPorts: ', ports);
}
readAvailablePorts();
any ideas how to solve would be appreciated.