Web端批量移动设备管理工具STF环境搭建for mac

文章格式并不规范,其实只是为了做个记录,记录自己在搭建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 node-uuid@1.4.8: Use uuid module instead
/usr/local/bin/stf -> /usr/local/lib/node_modules/stf/bin/stf

> dtrace-provider@0.8.3 install /usr/local/lib/node_modules/stf/node_modules/bunyan/node_modules/dtrace-provider
> node scripts/install.js

> dtrace-provider@0.7.1 install /usr/local/lib/node_modules/stf/node_modules/dtrace-provider
> node scripts/install.js

> bufferutil@1.3.0 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

> jpeg-turbo@0.4.0 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.<anonymous> (/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! jpeg-turbo@0.4.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the jpeg-turbo@0.4.0 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 node-uuid@1.4.8: Use uuid module instead
/usr/local/bin/stf -> /usr/local/lib/node_modules/stf/bin/stf
+ stf@2.3.0
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 node-uuid@1.4.8: 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的管理页面终于打开了。
悲催的是 无法正常连接设备。

image.png

看提示感觉像是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设备连接成功。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,736评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,167评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,442评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,902评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,302评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,573评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,847评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,562评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,260评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,531评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,021评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,367评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,016评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,068评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,827评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,610评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,514评论 2 269

推荐阅读更多精彩内容