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  [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编译进去

你可能感兴趣的:(Vue)