我尝试使用命令“sudo npm install serialport
”安装串口。
我正在运行raspbian
,我已使用apt get更新/升级。
我使用帖子2 here
中的说明安装了节点这是我得到的错误:
pi@raspberrypi ~/Programming/node $ sudo npm install serialport
npm http GET https://registry.npmjs.org/serialport
npm http 304 https://registry.npmjs.org/serialport
npm http GET https://registry.npmjs.org/bindings/0.3.0
npm http GET https://registry.npmjs.org/async/0.1.18
npm http GET https://registry.npmjs.org/sf/0.1.3
npm http GET https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/node-gyp/0.6.2
npm http 304 https://registry.npmjs.org/async/0.1.18
npm http 304 https://registry.npmjs.org/sf/0.1.3
npm http 304 https://registry.npmjs.org/bindings/0.3.0
npm http 304 https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/node-gyp/0.6.2
npm http GET https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/semver
npm http GET https://registry.npmjs.org/npmlog
npm http GET https://registry.npmjs.org/osenv
npm http GET https://registry.npmjs.org/tar
npm http GET https://registry.npmjs.org/which
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/fstream
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/rimraf
npm http 304 https://registry.npmjs.org/nopt
npm http 304 https://registry.npmjs.org/semver
npm http 304 https://registry.npmjs.org/osenv
npm http 304 https://registry.npmjs.org/tar
npm http 304 https://registry.npmjs.org/which
npm http 304 https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/npmlog
npm http 304 https://registry.npmjs.org/graceful-fs
npm http 304 https://registry.npmjs.org/fstream
npm http 304 https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/mkdirp
npm WARN engine tar@0.1.16: wanted: {"node":"~0.5.9 || 0.6 || 0.7 || 0.8"} (current: {"node":"v0.9.11-pre","npm":"1.2.12"})
npm http GET https://registry.npmjs.org/ansi
npm http GET https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/ansi
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/inherits
npm http 200 https://registry.npmjs.org/inherits
npm http 200 https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/block-stream
npm http 304 https://registry.npmjs.org/block-stream
> serialport@1.0.8 install /home/pi/node_modules/serialport
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack at install (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:69:16)
gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/node-gyp.js:56:37)
gyp ERR! stack at getNodeDir (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:223:20)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:105:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:577:7)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:97:17)
gyp ERR! stack at maybeClose (child_process.js:677:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:744:5)
gyp ERR! System Linux 3.6.11+
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/node_modules/serialport
gyp ERR! node -v v0.9.11-pre
gyp ERR! node-gyp -v v0.8.4
gyp ERR! not ok
npm ERR! serialport@1.0.8 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the serialport@1.0.8 install script.
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-gyp rebuild
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! System Linux 3.6.11+
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "serialport"
npm ERR! cwd /home/pi/Programming/node
npm ERR! node -v v0.9.11-pre
npm ERR! npm -v 1.2.12
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/pi/Programming/node/npm-debug.log
npm ERR! not ok code 0
显然我的节点版本太新了,我怎么能解决这个问题?
任何人都可以帮我解决这个问题吗?
由于
答案 0 :(得分:0)
通过删除此版本然后安装版本0.8.16来解决它。
由于
答案 1 :(得分:0)
我添加了同样的问题,在我的情况下,它是一个包的错误依赖(serialport强制为“1.0.x”)。我添加将旧包的 package.json 更改为:
{
"name": "oldPackage",
"dependencies": {
"serialport": "1.1.x"
}
}