Vue下使用serialport

用黑框框(命令)运行
1:先要安装 node-gyp

npm install -g node-gyp     (全局安装)

2.需要安装VS2017和python (我电脑里面有VS2017)
切记:python安装目录不要更改 也就是要装C盘

指令:如下

npm config set python python2.7  

npm config set msvs_version 2017

3.node-gyp 设置python 路径

npm config set python C:\Python27

环境配置完毕
测试命令:node-gyp

 Usage: node-gyp <command> [options]

where is one of:
- build - Invokes msbuild and builds the module
- clean - Removes any generated build files and the “out” dir
- configure - Generates MSVC project files for the current module
- rebuild - Runs “clean”, “configure” and “build” all at once
- install - Install node development files for the specified node version.
- list - Prints a listing of the currently installed node development files
- remove - Removes the node development files for the specified version

有这些东西出来 就说明你安装成功了

二:
如何使用串口通信serialport C++模块

进入自己vue-electron 项目 

1.   npm install   首先安装基础包
2.   npm install serialport   安装serialport包

 
进入\node_modules\serialport 目录

3.	 node-gyp configure 		 配置 serialport
	如果报错 gyp: binding.gyp not found 
	把serialport 替换了 
	然后 执行 
			1.node-gyp configure
			2.node-gyp build
			
			
4 在package.json
	加入	"rebuild": "./node_modules/.bin/electron-rebuild.cmd -f -w serialport"
	
	
然后 运行 npm run rebuild  就把serialport编译进去
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值