在node.js上安装Serialport时出错 [英] Error installing serialport on node.js
问题描述
我正在使用节点4.2.2运行Windows 10.我正在尝试与arduino一起使用,但是安装串行端口时一直遇到问题.我找不到任何帮助.这些是我运行npm install serialport时遇到的错误
I am running windows 10 with node 4.2.2. I am trying to set up to work with my arduino but i keep running into issues installing serialport. Nothing I can find is helping. These are the errors I get when i run npm install serialport
npm ERR! Windows_NT 10.0.10240
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "serialport" "-g"
npm ERR! node v4.2.2
npm ERR! npm v2.14.7
npm ERR! code ELIFECYCLE
npm ERR! serialport@2.0.2 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@2.0.2 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! c:\Users\john\Desktop\node-ardx\node_modules\johnny-five\npm-debug.log
推荐答案
确保已安装Python 2.7.如果这样做,则C ++编译器可能会出现问题. 安装Microsoft Build Tools 2015( https://www.microsoft.com/en-us/download/details.aspx?id=48159 ) 然后,在cmd行上将默认编译器更改为VS2015:
Make sure you have Python 2.7 installed. If you do, it may be an issue with the C++ compiler. Install Microsoft Build Tools 2015 (https://www.microsoft.com/en-us/download/details.aspx?id=48159) Then, on the cmd line change the default compiler to VS2015 :
$ npm config set msvs_version 2015
并且要特别确定:
$ set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140
如果您现在尝试安装Serialport,则会收到几个黄色警告,但安装没有任何问题.
If you now try to install serialport you'll get a couple of yellow warnings but installs without any issue.
干杯!
这篇关于在node.js上安装Serialport时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!