1、npm安装 (sudo apt-get install npm),可能需要先软件更新(sudo apt-get update)
2、libavahi-compat-libdnssd-dev安装(sudo apt-get install libavahi-compat-libdnssd-dev)
3、homebridge安装(sudo npm install -g --unsafe-perm homebridge)
可能出现下面的错误
/bin/sh: 1: node: not foundgyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gypgyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)gyp ERR! System Linux 3.13.0-32-genericgyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"gyp ERR! cwd /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/curve25519-ngyp ERR! node -v v0.10.25gyp ERR! node-gyp -v v0.10.10gyp ERR! not ok npm WARN This failure might be due to the use of legacy binary "node"npm WARN For further explanations, please read/usr/share/doc/nodejs/README.Debian npm ERR! Error: ENOENT, lstat '/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/node_modules/nan/nan_persistent_pre_12_inl.h'npm ERR! If you need help, you may report this log at:npm ERR!npm ERR!Traceback (most recent call last): or email it to:npm ERR!npm ERR! System Linux 3.13.0-32-genericnpm File "/usr/share/node-gyp/gyp/gyp", line 9, inload_entry_point('gyp==0.1', 'console_scripts', 'gyp')()
File "/usr/lib/python2.7/dist-packages/gyp/__init__.py", line 547, in script_main
ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "--unsafe-perm" "homebridge"
return main(sys.argv[1:])
File "/usr/lib/python2.7/dist-packages/gyp/__init__.py", line 540, in main
npmreturn gyp_main(args)
File "/usr/lib/python2.7/dist-packages/gyp/__init__.py", line 505, in gyp_main
ERR! 'cwd': os.getcwd(),
OSError: [Errno 2] No such file or directory
cwd /home/lee
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/node_modules/nan/nan_persistent_pre_12_inl.h
npm ERR! fstream_path /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/mdns/node_modules/nan/nan_persistent_pre_12_inl.h
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
gyp ERR!ERR! fstream_stackstack /usr/lib/nodejs/fstream/lib/writer.js:284:26
at ChildProcess.EventEmitter.emit (events.js:98:17)
npmgyp ERR!ERR! fstream_stack Object.oncomplete (fs.js:107:15)
stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.13.0-32-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/node_modules/ed25519
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian
npm ERR! weird error 1
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/lee/npm-debug.log
npm ERR! not ok code 0
解决方案为
sudo apt-get install nodejs
sudo apt-get install nodes-legacy
sudo npm install -g --unsafe-perm homebridge
或者
sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo apt-get install git
sudo npm -g install npm@latest
sudo npm install -g --unsafe-perm homebridge
运行sudo homebridge,出现如下错误
/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Camera.js:28 let options = { ^^^SyntaxError: Unexpected strict mode reserved word at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.(/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/index.js:3:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
需要升级nodejs(node -v查看版本),升级为6.8.0