serialport / node-serialport

Access serial ports with JavaScript. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!

Home Page:https://serialport.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using No Reaction in Vue+Electron+typescript

xiaguangbo opened this issue · comments

SerialPort Version

12.0.0

Node Version

18.13.0

Electron Version

26.2.0

Platform

Linux debian 6.1.0-12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.52-1 (2023-09-07) x86_64 GNU/Linux

Architecture

x64

Hardware or chipset of serialport

all

What steps will reproduce the bug?

app.whenReady().then(() => {
...
console.log('hhh')
  const SerialPort = require('serialport')
  {
    (async () => {
      try {
        let ports = await SerialPort.list();
        console.log(ports); // 打印串口列表
      } catch (error) {
        console.log(error);
      }
    })()
  }
})

What happens?

stdout: hhh

stderr: (node:17787) UnhandledPromiseRejectionWarning: Error: No native build was found for platform=linux arch=x64 runtime=electron abi=116 uv=1 libc=glibc node=18.16.1 electron=26.2.0
    loaded from: /media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project

    at load.resolve.load.path (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:4980:13)
    at load (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:4943:34)
    at node_modules/.store/@serialport+bindings-cpp@12.0.1/node_modules/@serialport/bindings-cpp/dist/load-bindings.js (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:5139:48)
    at __require (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:8:50)
    at node_modules/.store/@serialport+bindings-cpp@12.0.1/node_modules/@serialport/bindings-cpp/dist/darwin.js (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:5428:27)
    at __require (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:8:50)
    at node_modules/.store/@serialport+bindings-cpp@12.0.1/node_modules/@serialport/bindings-cpp/dist/index.js (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:6125:20)
    at __require (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:8:50)
    at node_modules/.store/serialport@12.0.0/node_modules/serialport/dist/serialport.js (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:6158:26)
    at __require (/media/xiaguangbo/新加卷/windows/project/temprature_monitor/vue-project/dist/background.js:8:50)
(Use `electron --trace-warnings ...` to show where the warning was created)
(node:17787) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

stderr: [17828:0912/212349.223296:ERROR:command_buffer_proxy_impl.cc(128)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
[17835:0912/212349.223317:ERROR:command_buffer_proxy_impl.cc(128)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.

What should have happened?

...

Additional information

It is normal to use JavaScript in a simple nodejs project, but there is no output when using it in Electron+TS

commented

你解决了么