文章格式并不规范,其实只是为了做个记录,记录自己在搭建stf环境的时候所遇到各种坑,貌似一个简单的环境搭建,前前后后差不多五天时间。。。真心快崩溃了。对于真正搭建过此环境的人来说,可能会有借鉴作用吧,至于没接触过的童鞋,用处不大,建议就不要往下看了,就是这么任性~~~~
各种工具的下载安装:
1.安装xcode和xcode命令行工具(已有未验证这步)
Xcode:直接在 App Store 下载安装
Xcode Command Line Tools:在terminal中输入以下命令,然后在弹出的安装步骤中猛点下一步自动安装。
xcode-select --install
2.安装MacPorts,后面会用到port(参照MacPorts的安装)
3.SDK环境安装—已有,忽略。
4.nodejs的安装 — 已有,忽略。
[https://nodejs.org/en/](https://nodejs.org/en/)
验证:
node -v
v6.11.0
5.安装bower:
sudo npm install bower -g
验证:
bower -v
6.安装rethinkdb(这里建议通过pgk安装)
[rethinkdb](https://www.rethinkdb.com/docs/install/)
7.安装graphicsmagick
do port install graphicsmagick
8.安装libsodium
sudo port install libsodium
9.安装zeromp
sudo port install zmq
10.安装protobuf
sudo port install protobuf-cpp
11.安装pkg-config
sudo port install pkgconfig
12.安装stf
sudo npm install -g stf
后续有报错:
npm WARN deprecated [email protected]: Use uuid module instead
/usr/local/bin/stf -> /usr/local/lib/node_modules/stf/bin/stf
> [email protected] install /usr/local/lib/node_modules/stf/node_modules/bunyan/node_modules/dtrace-provider
> node scripts/install.js
> [email protected] install /usr/local/lib/node_modules/stf/node_modules/dtrace-provider
> node scripts/install.js
> [email protected] install /usr/local/lib/node_modules/stf/node_modules/bufferutil
> node-gyp rebuild
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/zrck/.node-gyp/6.10.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/stf/node_modules/bufferutil/.node-gyp"
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
> [email protected] install /usr/local/lib/node_modules/stf/node_modules/jpeg-turbo
> node-pre-gyp install --fallback-to-build
gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/zrck/.node-gyp/6.10.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/.node-gyp"
make: *** No rule to make target `../.node-gyp/6.10.2/include/node/common.gypi', needed by `Makefile'. Stop.
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 16.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/lib/binding/node-v48-darwin-x64/jpegturbo.node" "--module_name=jpegturbo" "--module_path=/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/lib/binding/node-v48-darwin-x64"
gyp ERR! cwd /usr/local/lib/node_modules/stf/node_modules/jpeg-turbo
gyp ERR! node -v v6.10.2
gyp ERR! node-gyp -v v3.4.0
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/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/lib/binding/node-v48-darwin-x64/jpegturbo.node --module_name=jpegturbo --module_path=/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/lib/binding/node-v48-darwin-x64' (1)
node-pre-gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:886:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Darwin 16.3.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/stf/node_modules/jpeg-turbo
node-pre-gyp ERR! node -v v6.10.2
node-pre-gyp ERR! node-pre-gyp -v v0.6.19
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/lib/binding/node-v48-darwin-x64/jpegturbo.node --module_name=jpegturbo --module_path=/usr/local/lib/node_modules/stf/node_modules/jpeg-turbo/lib/binding/node-v48-darwin-x64' (1)
/usr/local/lib
└── (empty)
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "stf"
npm ERR! node v6.10.2
npm ERR! npm v3.10.10
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! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jpeg-turbo 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 information on how to open an issue for this project with:
npm ERR! npm bugs jpeg-turbo
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls jpeg-turbo
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/zrck/npm-debug.log
npm ERR! code
尝试解决:
https://testerhome.com/topics/2988
https://github.com/node-inspector/v8-debug/issues/7
http://blog.csdn.net/qq_26819733/article/details/55549241?locationNum=11&fps=1
https://testerhome.com/topics/5206
最后 重装nodejs (采用官网pkg下载安装)
bogon:~ zrck$ node -v
v8.1.2
bogon:~ zrck$ npm -v
5.0.3
之后继续尝试安装
sudo npm install -g stf
貌似正常了 ,但后来一直死循环一般的提示:
gyp WARN EACCES user "root" does not have permission to access the dev dir "/usr/local/lib/node_modules/stf/node_modules/zmq/.node-gyp/8.1.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/stf/node_modules/zmq/.node-gyp"
字面意思应该是没有root权限操作,尝试:
sudo chmod -R 777 /var/root
然后继续重试:sudo npm install -g stf 成功
sudo npm install -g stf
npm WARN deprecated [email protected]: Use uuid module instead
/usr/local/bin/stf -> /usr/local/lib/node_modules/stf/bin/stf
+ [email protected]
updated 1 package in 30.743s
题外Tip:可能还会有一种可能造成无权限,是苹果系统自带的SIP安全机制
OS X El Capitan 中有一个跟安全相关的模式叫 SIP(System Integrity Protection ),它禁止让软件以 root 身份来在 Mac 上运行,在升级到 OS X 10.11 中或许你就会看到部分应用程序被禁用了,这些或许是你通过终端或者第三方软件源安装。对于大多数用户来说,这种安全设置很方便,但是也有些开发者或者高级 Mac 用户不需要这样的设置,关闭方法:
1.重启 Mac,按住 Command+R 键直到 Apple logo 出现,进入 Recovery Mode
2.点击 Utilities > Terminal
3.在 Terminal 中输入 csrutil disable,之后回车
》》》重启 Mac
但可以看到 上面有一个警告:
npm WARN deprecated [email protected]: Use uuid module instead
搜了下解决办法:
google了下有网友给出的答案是:the node-uuid module deprecated,u need to install uuid module.
npm install -g uuid
或者
npm uninstall --save node-uuid
npm install --save uuid
依旧无效,但不影响stf的安装,选择忽略了。
运行时报错:
/usr/local/lib/node_modules/stf/node_modules/bindings/bindings.js:91
throw err
^
Error: Could not locate the bindings file. Tried:
→ /usr/local/lib/node_modules/stf/node_modules/zmq/build/zmq.node
→ /usr/local/lib/node_modules/stf/node_modules/zmq/build/Debug/zmq.node
→ /usr/local/lib/node_modules/stf/node_modules/zmq/build/Release/zmq.node
→ /usr/local/lib/node_modules/stf/node_modules/zmq/out/Debug/zmq.node
→ /usr/local/lib/node_modules/stf/node_modules/zmq/Debug/zmq.node
→ /usr/local/lib/node_modules/stf/node_modules/zmq/out/Release/zmq.node
→ /usr/local/lib/node_modules/stf/node_modules/zmq/Release/zmq.node
→ /usr/local/lib/node_modules/stf/node_modules/zmq/build/default/zmq.node
→ /usr/local/lib/node_modules/stf/node_modules/zmq/compiled/6.10.1/darwin/x64/zmq.node
at bindings (/usr/local/lib/node_modules/stf/node_modules/bindings/bindings.js:88:9)
at Object. (/usr/local/lib/node_modules/stf/node_modules/zmq/lib/index.js:6:30)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/usr/local/lib/node_modules/stf/node_modules/zmq/index.js:2:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
项目GitHub里issues里有相关问题解决方案,作者建议的是将nodejs升级到最新版本,重试之后 依旧存在问题。
后来怀疑是nodejs或者stf在安装时丢文件导致,试了下淘宝镜像
https://npm.taobao.org/package/stf
执行命令来全局安装cnpm
npm install -g cnpm --registry=[https://registry](https://registry).[npm.taobao.org](http://npm.taobao.org)
cnpm install stf -g
。。。。。看到了曙光,进入了stf的管理页面终于打开了。
悲催的是 无法正常连接设备。
看提示感觉像是jpeg-turbo安装有问题:
npm install jpeg-turbo --registry=https://registry.npm.taobao.org
但依旧无效果
最后,重新将nodejs卸载,stf卸载,nodejs采用资源文件编译安装,stf 通过:npm install stf -g安装,成功进入网页,连接魅族note2手机无法连接:
Starting service: Intent { cmp=jp.co.cyberagent.stf/.Service } Error: Not found; no service started.
目前未能找到有效的解决办法。
其他设备:华为G750连接成功,手头一台android版pos设备连接成功。