npm 安装 node-hid 失败(安装最新版本的 Nodejs 失败)
Posted
技术标签:
【中文标题】npm 安装 node-hid 失败(安装最新版本的 Nodejs 失败)【英文标题】:npm fail to install node-hid (faild to install last version of Nodejs) 【发布时间】:2014-03-03 10:40:18 【问题描述】:我正在尝试在我的 Raspberry Pi (Raspbian) 上安装 node-hid。 但是 node-hid 需要高版本的 Nodejs 才能工作(>= 0.8),而我的版本只有 0.6.19。
所以,我尝试用nvm安装Nodejs v0.10.26...nvm安装成功nodejs v0.10.26,但是npm仍然使用旧版本的Nodejs。 Nodejs v0.10.26 版本如何在整个系统中使用?以及如何安装 node-hid ?
感谢您的帮助
这是我尝试安装 node-hid 时得到的代码:
pi@raspberrypi ~ $ sudo npm install -g node-hid
npm http GET https://registry.npmjs.org/node-hid
npm ERR! Error: failed to fetch from registry: node-hid
npm ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR! at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR! at Request.emit (events.js:88:20)
npm ERR! at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:209:10)
npm ERR! at ClientRequest.emit (events.js:67:17)
npm ERR! at ClientRequest.onError (/usr/lib/nodejs/request/tunnel.js:164:21)
npm ERR! at ClientRequest.g (events.js:156:14)
npm ERR! You may report this log at:
npm ERR! <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR! reportbug --attach /home/pi/npm-debug.log npm
npm ERR!
npm ERR! System Linux 3.6.11+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "node-hid"
npm ERR! cwd /home/pi
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: node-hid
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/npm-debug.log
npm not ok
在 npm-debug.log 中:
info it worked if it ends with ok
verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'install', 'node-hid', '-g' ]
info using npm@1.1.4
info using node@v0.6.19
verbose config file /root/.npmrc
verbose config file /usr/etc/npmrc
verbose config file /usr/share/npm/npmrc
silly exec /usr/bin/nodejs "/usr/share/npm/bin/npm-get-uid-gid.js" "nobody" 1000
silly spawning [ '/usr/bin/nodejs',
silly spawning [ '/usr/share/npm/bin/npm-get-uid-gid.js', 'nobody', 1000 ],
silly spawning null ]
silly output from getuid/gid "uid":65534,"gid":1000
silly output from getuid/gid
verbose cache add [ 'node-hid', null ]
silly cache add: name, spec, args [ undefined, 'node-hid', [ 'node-hid', null ] ]
verbose parsed url pathname: 'node-hid', path: 'node-hid', href: 'node-hid'
verbose addNamed [ 'node-hid', '' ]
verbose addNamed [ null, '' ]
silly name, range, hasData [ 'node-hid', '', false ]
verbose raw, before any munging node-hid
verbose url resolving [ 'https://registry.npmjs.org/', './node-hid' ]
verbose url resolved https://registry.npmjs.org/node-hid
http GET https://registry.npmjs.org/node-hid
ERR! Error: failed to fetch from registry: node-hid
ERR! at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
ERR! at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
ERR! at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
ERR! at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
ERR! at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
ERR! at Request.emit (events.js:88:20)
ERR! at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:209:10)
ERR! at ClientRequest.emit (events.js:67:17)
ERR! at ClientRequest.onError (/usr/lib/nodejs/request/tunnel.js:164:21)
ERR! at ClientRequest.g (events.js:156:14)
ERR! You may report this log at:
ERR! <http://bugs.debian.org/npm>
ERR! or use
ERR! reportbug --attach /home/pi/npm-debug.log npm
ERR!
ERR! System Linux 3.10.25+
ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "node-hid" "-g"
ERR! cwd /home/pi
ERR! node -v v0.6.19
ERR! npm -v 1.1.4
ERR! message failed to fetch from registry: node-hid
verbose exit [ 1, true ]
【问题讨论】:
/home/pi/npm-debug.log
中有什么内容?
你连接到互联网了吗?多次尝试后是否收到相同的错误?
是的,我已经连接到互联网了。。我尝试了很多次,仍然无法正常工作!
【参考方案1】:
以下对我有用:
检查您的系统是最新的:
sudo apt-get update
sudo apt-get upgrade
安装最新版本的节点
sudo wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb
检查是否安装了最新版本的节点
node -v
为 node-hid 安装依赖项
不完全确定它是否都需要(有些可能已经安装)但它是唯一对我有用的东西..
sudo apt-get install g++ curl
sudo apt-get install libssl-dev apache2-utils
sudo apt-get install build-essential
sudo apt-get install pkg-config
sudo npm install node-gyp -g
sudo apt-get install git-core
sudo apt-get install libudev-dev
sudo apt-get install libusb-1.0-0-dev
安装节点隐藏
npm install node-hid
注意: 上面的节点安装只适用于 Raspbian,如果你想在 Ubuntu 中进行实验,请使用以下代码安装节点,其他一切都保持不变:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
【讨论】:
以上是关于npm 安装 node-hid 失败(安装最新版本的 Nodejs 失败)的主要内容,如果未能解决你的问题,请参考以下文章