如何在Node上安装串行端口模块?

问题描述 投票:2回答:1

我在Node上安装串行模块时遇到问题。我将Raspbian服务器用于橙色pi零H2。

root@OrangePI:/home/node# npm install serialport

返回

npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN engine [email protected]: wanted: {"node":">=8.6.0"} (current:     {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine @serialport/[email protected]: wanted: {"node":">=8.6.0"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine [email protected]: wanted: {"node":">=6"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine [email protected]: wanted: {"node":">=6"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine [email protected]: wanted: {"node":">=8"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine [email protected]: wanted: {"node":">=8"} (current: {"node":"4.9.1","npm":"2.15.11"})
npm WARN engine [email protected]: wanted: {"node":">= 6"} (current: {"node":"4.9.1","npm":"2.15.11"})

...

> @serialport/[email protected] install /home/node/node_modules/serialport/node_modules/@serialport/bindings > prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild

/home/node/node_modules/serialport/node_modules/@serialport/bindings/node_modules/prebuild-install/node_modules/simple-get/index.js:18
const { hostname, port, protocol, auth, path } = url.parse(opts.url) // eslint-disable-line node/no-deprecated-api
      ^
SyntaxError: Unexpected token {
     at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/node/node_modules/serialport/node_modules/@serialport/bindings/node_modules/prebuild-install/download.js:3:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)

我在linux上经验很少...但是这是我的印象还是所声明的常量确实未命名?

make: Entering directory 
'/home/node/node_modules/serialport/node_modules/@serialport/bindings/build'
    CXX(target) Release/obj.target/bindings/src/serialport.o
make: g++: Command not found
bindings.target.mk:97: recipe for target 'Release/obj.target/bindings/src/serialport.o' failed
make: *** [Release/obj.target/bindings/src/serialport.o] Error 127
make: Leaving directory '/home/node/node_modules/serialport/node_modules/@serialport/bindings/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/opt/node/lib/node_modules/npm/node_modules/node-        gyp/lib/build.js:276:23)
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:211:12)
gyp ERR! System Linux 3.4.39
gyp ERR! command "/opt/node/bin/node" "/opt/node/lib/node_modules/npm/node_modules/node-    gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/node/node_modules/serialport/node_modules/@serialport/bindings
gyp ERR! node -v v4.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm ERR! Linux 3.4.39
npm ERR! argv "/opt/node/bin/node" "/opt/node/bin/npm" "install" "serialport"
npm ERR! node v4.9.1
npm ERR! npm  v2.15.11
npm ERR! code ELIFECYCLE

npm ERR! @serialport/[email protected] install: `prebuild-install --tag-prefix @serialport/bindings@ ||     node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @serialport/[email protected] install script 'prebuild-install --tag-prefix     @serialport/bindings@ || node-gyp rebuild'.
npm ERR! This is most likely a problem with the @serialport/bindings package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs @serialport/bindings
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls @serialport/bindings
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/node/npm-debug.log

日志文件的最后部分

5807 info install [email protected]
5808 info postinstall [email protected]
5809 verbose unlock done using /root/.npm/_locks/prebuild-install-da7fa1c0b3187458.lock for /home/node/node_modules/serialport/node_modules/@serialport/bindings/node_modules/prebuild-install
5810 verbose about to build /home/node/node_modules/serialport/node_modules/@serialport/bindings
5811 info build /home/node/node_modules/serialport/node_modules/@serialport/bindings
5812 info linkStuff @serialport/[email protected]
5813 silly linkStuff @serialport/[email protected] has /home/node/node_modules/serialport/node_modules     as its parent node_modules
5814 verbose linkBins @serialport/[email protected]
5815 verbose linkMans @serialport/[email protected]
5816 verbose rebuildBundles @serialport/[email protected]
5817 verbose rebuildBundles [ '.bin', '@serialport', 'bindings', 'nan', 'prebuild-install' ]
5818 info install @serialport/[email protected]
5819 verbose unsafe-perm in lifecycle true
5820 info @serialport/[email protected] Failed to exec install script
5821 verbose unlock done using /root/.npm/_locks/serialport-bindings-291f31ff80e6691d.lock for     /home/node/node_modules/serialport/node_modules/@serialport/bindings
5822 verbose about to build /home/node/node_modules/serialport
5823 verbose unlock done using /root/.npm/_locks/serialport-a4250c37e3372508.lock for     /home/node/node_modules/serialport
5824 verbose stack Error: @serialport/[email protected] install: `prebuild-install --tag-prefix     @serialport/bindings@ || node-gyp rebuild`
5824 verbose stack Exit status 1
5824 verbose stack     at EventEmitter.<anonymous> (/opt/node/lib/node_modules/npm/lib/utils/lifecycle.js:217:16)
5824 verbose stack     at emitTwo (events.js:87:13)
5824 verbose stack     at EventEmitter.emit (events.js:172:7)
5824 verbose stack     at ChildProcess.<anonymous>     (/opt/node/lib/node_modules/npm/lib/utils/spawn.js:24:14)
5824 verbose stack     at emitTwo (events.js:87:13)
5824 verbose stack     at ChildProcess.emit (events.js:172:7)
5824 verbose stack     at maybeClose (internal/child_process.js:862:16)
5824 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:222:5)
5825 verbose pkgid @serialport/[email protected]
5826 verbose cwd /home/node
5827 error Linux 3.4.39
5828 error argv "/opt/node/bin/node" "/opt/node/bin/npm" "install" "--unsafe-perm" "serialport"
5829 error node v4.9.1
5830 error npm  v2.15.11
5831 error code ELIFECYCLE
5832 error @serialport/[email protected] install: `prebuild-install --tag-prefix @serialport/bindings@     || node-gyp rebuild`
5832 error Exit status 1
5833 error Failed at the @serialport/[email protected] install script 'prebuild-install --tag-prefix     @serialport/bindings@ || node-gyp rebuild'.
5833 error This is most likely a problem with the @serialport/bindings package,
5833 error not with npm itself.
5833 error Tell the author that this fails on your system:
5833 error     prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
5833 error You can get information on how to open an issue for this project with:
5833 error     npm bugs @serialport/bindings
5833 error Or if that isn't available, you can get their info via:
5833 error
5833 error     npm owner ls @serialport/bindings
5833 error There is likely additional logging output above.
5834 verbose exit [ 1, true ]

默认情况下未安装该版本的make,欢迎任何建议,感谢您的宝贵时间。

npm node-modules raspbian node-serialport orange-pi
1个回答
0
投票

更新您的nodejs

npm WARN引擎[email protected]:想要的:{“ node”:“> = 8.6.0”}(当前:{“ node”:“ 4.9.1”,“ npm”:“ 2.15.11”}} )

您当前的版本不了解ES6语法

const {主机名,端口,协议,身份验证,路径} = url.parse(opts.url)//禁止行禁用节点/未弃用的api^语法错误:意外令牌{

© www.soinside.com 2019 - 2024. All rights reserved.