Skip to content

Instantly share code, notes, and snippets.

@dohzoh
Last active November 16, 2016 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dohzoh/92b2c6e31dea68f91c823b5cb272a98a to your computer and use it in GitHub Desktop.
Save dohzoh/92b2c6e31dea68f91c823b5cb272a98a to your computer and use it in GitHub Desktop.
CentOS6でElectronベースNightmareを動かす ref: http://qiita.com/dozo/items/de393588d5c267794ced
$ sudo yum install xorg-X11-server-Xvfb
パッケージ xorg-X11-server-Xvfb は利用できません。
* おそらくの意味: xorg-x11-server-Xvfb
エラー: 何もしません
$ sudo yum update
http://mirror.centos.org/centos/6/SCL/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
他のミラーを試します。
To address this issue please refer to the below knowledge base article
https://access.redhat.com/articles/1320623
If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.
$ nodebrew install-binary stable
$ node -v
v7.1.0
$ npm -v
3.10.9
$ npm install -g --save-dev electron nightmare
$ vi example.js
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: true });
nightmare
.goto('http://yahoo.com')
.type('form[action*="/search"] [name=p]', 'github nightmare')
.click('form[action*="/search"] [type=submit]')
.wait('#main')
.evaluate(function () {
return document.querySelector('#main .searchCenterMiddle li a').href
})
.end()
.then(function (result) {
console.log(result)
})
.catch(function (error) {
console.error('Search failed:', error);
});
$ DEBUG=* node example.js
nightmare queuing process start +0ms
nightmare queueing action "goto" for http://www.yahoo.com +127ms
nightmare queueing action "type" +13ms
nightmare queueing action "click" +0ms
nightmare queueing action "wait" +0ms
nightmare queueing action "evaluate" +0ms
nightmare queueing action "screenshot" +1ms
nightmare running +1ms
nightmare electron child process exited with code 1: general error - you may need xvfb +143ms
nightmare electron child process not started yet, skipping kill. +2ms
$ xvfb-run node example.js
$ DEBUG=* node nightmare.js
・・・
nightmare running +1ms
electron:stderr /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron:
error while loading shared libraries: libXss.so.1:
cannot open shared object file: No such file or directory +63ms
nightmare electron child process exited with code 127: command not found
- you may not have electron installed correctly +7ms
nightmare electron child process not started yet, skipping kill
$ sudo yum install libXScrnSaver-devel
$ DEBUG=* node nightmare.js
・・・
nightmare running +1ms
electron:stderr /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron) +201ms
electron:stderr /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron) +2ms
electron:stderr /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.5' not found (required by /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron) +1ms
electron:stderr /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/libnode.so) +15ms
nightmare electron child process exited with code 1: general error - you may need xvfb +72ms
nightmare electron child process not started yet, skipping kill. +2ms
$ DEBUG=* node nightmare.js
・・・
nightmare running +1ms
electron:stderr /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron: symbol lookup error: /home/dozo/.nodebrew/node/v5.5.0/lib/node_modules/electron/dist/electron: undefined symbol: g_bytes_unref
$ sudo yum remove centos-release-SCL
$ sudo yum update
$ sudo yum install centos-release-scl
$ sudo yum update
$ wget http://ftp.gnome.org/pub/gnome/sources/glib/2.32/glib-2.32.4.tar.xz
$ tar Jxvf glib-2.32.4.tar.xz
$ cd glib-2.32.4
$ ./configure
$ make
$ sudo make install
$ wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.4/gcc-4.8.4.tar.gz
$ tar xvfz
$ cd gcc
$ ./configure
$ make # ←時間に余裕があるときにビルドするように(筆者は5時間ほどかかった)
$ sudo make install # ←対象ファイルはひとつだけなので手動で切り替えも可
$ sudo vi /etc/ld.so.conf.d/0default.conf
/usr/local/lib/
/usr/lib/
$ sudo ldconfig
$ sudo ldconfig -p | grep libstdc++.so # 登録確認
libstdc++.so.6 (libc6,x86-64) => /usr/lib64/libstdc++.so.6
libstdc++.so.6 (libc6) => /usr/local/lib/libstdc++.so.6 ←これが含まれればOK
libstdc++.so (libc6) => /usr/local/lib/libstdc++.so
$ sudo ldconfig -p | grep libgobject # 登録確認
libgobject-2.0.so.0 (libc6,x86-64) => /usr/local/lib/libgobject-2.0.so.0 ←これが含まれればOK
libgobject-2.0.so.0 (libc6,x86-64) => /lib64/libgobject-2.0.so.0
libgobject-2.0.so (libc6,x86-64) => /usr/local/lib/libgobject-2.0.so
libgobject-2.0.so (libc6,x86-64) => /usr/lib64/libgobject-2.0.so
$ sudo yum install xorg-x11-server-Xvfb "xorg-x11-fonts*"
$ sudo yum -y groupinstall "Japanese Support"
$ which xvfb-run
/usr/bin/xvfb-run
$ curl -L git.io/nodebrew | perl - setup
$ cat >> ~/.bashrc
export PATH=$HOME/.nodebrew/current/bin:$PATH
export NODE_PATH=$HOME/.nodebrew/current/lib/node_modules/
$ source ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment