2015-09-27 152 views
0

我无法在Mac上安装模块Serialport。因此,无法通过Johnny-five将Arduino与我的电脑连接起来。它说这个错误:在NodeJS(mac)上为Johnny-Five安装Serialport模块

gyp: /Users/me/.node-gyp/4.0.0/common.gypi not found (cwd: /usr/local/lib/node_modules/serialport) while reading includes of binding.gyp while trying to load binding.gyp 
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1 
gyp ERR! stack  at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:357:16) 
gyp ERR! stack  at emitTwo (events.js:87:13) 
gyp ERR! stack  at ChildProcess.emit (events.js:172:7) 
gyp ERR! stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) 
gyp ERR! System Darwin 14.5.0 
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64/serialport.node" "--module_name=serialport" "--module_path=/usr/local/lib/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64" 
gyp ERR! cwd /usr/local/lib/node_modules/serialport 
gyp ERR! node -v v4.0.0 
gyp ERR! node-gyp -v v2.0.2 
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64' (1) 
node-pre-gyp ERR! stack  at ChildProcess.<anonymous> (/usr/local/lib/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29) 
node-pre-gyp ERR! stack  at emitTwo (events.js:87:13) 
node-pre-gyp ERR! stack  at ChildProcess.emit (events.js:172:7) 
node-pre-gyp ERR! stack  at maybeClose (internal/child_process.js:817:16) 
node-pre-gyp ERR! stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) 
node-pre-gyp ERR! System Darwin 14.5.0 
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/serialport/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" 
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/serialport 
node-pre-gyp ERR! node -v v4.0.0 
node-pre-gyp ERR! node-pre-gyp -v v0.6.7 
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64/serialport.node --module_name=serialport --module_path=/usr/local/lib/node_modules/serialport/build/serialport/v1.7.4/Release/node-v46-darwin-x64' (1) 
npm ERR! Darwin 14.5.0 
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "serialport" "-g" 
npm ERR! node v4.0.0 
npm ERR! npm v2.14.2 
npm ERR! code ELIFECYCLE 

npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] 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. 

我试图在本地安装它,全球,查找解决方案,但没有任何帮助。也许是因为我最近更新了NodeJS 4.0.0。但我试图降级它,结果仍然是一样的。安装了Visual Studio和Python(版本2.x)(很多人都没有使用“解决方案”)。

你有什么想法如何解决它?非常感谢。

回答

0

我有同样的问题。一位同事告诉我说使用NVM可能会奏效。我现在正在处理这个问题

+0

Instiling NVM工作得很好! – Vic

0

在回答这个问题时,Node-Serialport不支持Node 4.x.您需要安装0.12.x或0.10.x.详情请按照this issue