Npm 串行端口电子

Npm 串行端口电子,npm,serial-port,electron,Npm,Serial Port,Electron,我正在尝试运行一个简单的electron应用程序,从端口COM4读取和写入值,我已经下载并正确安装了node.js和serialport io。我就是这样做的: $ git clone https://github.com/electron/electron-quick-start # Go into the repository $ cd electron-quick-start # Install the dependencies and run $ npm install &&am

我正在尝试运行一个简单的electron应用程序,从端口COM4读取和写入值,我已经下载并正确安装了node.js和serialport io。我就是这样做的:

$ git clone https://github.com/electron/electron-quick-start
# Go into the repository
$ cd electron-quick-start
# Install the dependencies and run
$ npm install && npm start
一旦这样做了。安装serialport库

$ npm install --save serialport 
$ npm install --save-dev electron-rebuild  
重建电子

$ ./node_modules/.bin/electron-rebuild
$ npm rebuild
这是我的index.html

        var SerialPort = require('serialport');
        const Readline = serialPort.parsers.Readline;

        //initialize serialport with 115200 baudrate.
        var sp = new serialPort('COM4', {
            baudRate: 115200,
        });

        function writeonSer(data){
            //Write the data to serial port.
            sp.write( data, function(err) {
                if (err) {
                    return console.log('Error on write: ', err.message);
                }
                console.log('message written');
            });

        }
    </script>
    <script>
        // You can also require other files to run in this process
        require('./renderer.js')
    </script>

请帮忙!谢谢。

< P>我通过安装VisualStudioC++开发包,成功地在Windows环境下获得了GithuB/CONTROLPORT/Engon SerialPoT。我犯了一个和你以前犯的类似的错误。具体来说,它需要MSV构建工具。工具可以在这里使用:)


我还尝试使用NVM Windows并运行SerialPort/Bindings目录文件中指定的模块版本。这实际上不起作用,所以可能错误报告不正确?无论如何,希望这有帮助

> P>我通过安装VisualStudioC++开发包,成功地在Windows环境下获得GithuB/CONTROLPORT/Engon SerialPalt。我犯了一个和你以前犯的类似的错误。具体来说,它需要MSV构建工具。工具可以在这里使用:)


我还尝试使用NVM Windows并运行SerialPort/Bindings目录文件中指定的模块版本。这实际上不起作用,所以可能错误报告不正确?无论如何,希望这有帮助

你的node.js是最新的吗?是的,我安装了npmnpm@latest-你看过这个样板吗?我不知道你的项目在哪里。但是如果你想为自己节省一些时间,你可以以此为出发点。我设置它的唯一问题是对一个或两个目录的写入/执行权限。你的node.js是最新的吗?是的,我安装了npmnpm@latest-你看过这个样板吗?我不知道你的项目在哪里。但是如果你想为自己节省一些时间,你可以以此为出发点。我设置它的唯一问题是对一个或两个目录的写入/执行权限。
Uncaught Error: The module '\\?\C:\Users\atorres\Desktop\SerialPort\electron-quick-start\node_modules\@serialport\bindings\build\Release\bindings.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 73. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at process.func (electron/js2c/asar.js:155)
    at process.func [as dlopen] (electron/js2c/asar.js:155)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:828)
    at Object.func (electron/js2c/asar.js:155)
    at Object.func [as .node] (electron/js2c/asar.js:155)
    at Module.load (internal/modules/cjs/loader.js:645)
    at Function.Module._load (internal/modules/cjs/loader.js:560)
    at Module.require (internal/modules/cjs/loader.js:685)
    at require (internal/modules/cjs/helpers.js:16)
    at bindings (C:\Users\atorres\Des…ngs\bindings.js:112)