はじめに
wscat
コマンドを使いたくなったので, nvm
で Node.js をインストールして, npm
で wscat
をインストールしたときの記録です.
ログ
実行環境は,
- Mac OS X 10.8.5
- Zsh 4.3.11
です.
nvm インストール
コマンドライン一行でインストールできます.
~/work % curl https://raw.githubusercontent.com/creationix/nvm/v0.11.1/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3329 100 3329 0 0 9205 0 --:--:-- --:--:-- --:--:-- 11639
=> Downloading nvm from git to '/Users/********/.nvm'
=> Cloning into '/Users/********/.nvm'...
remote: Counting objects: 2710, done.
remote: Total 2710 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (2710/2710), 514.65 KiB | 95.00 KiB/s, done.
Resolving deltas: 100% (1478/1478), done.
Checking connectivity... done.
Note: checking out 'v0.11.1'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 7a423b7... v0.11.1
Deleted branch master (was 080f214).
=> Source string already in /Users/********/.zshrc
=> Close and reopen your terminal to start using nvm
ターミナルを閉じろと言われていますが,閉じずに次のコマンドを実行します.
~/work % exec zsh --login
Node.js のインストール
ls-remote
で確認できる最新のものをインストールします.
~/work % nvm ls-remote | tail
v0.11.5
v0.11.6
v0.11.7
v0.11.8
v0.11.9
v0.11.10
v0.11.11
v0.11.12
v0.11.13
v0.11.14
~/work % nvm install v0.11.14
############################################################################################### 100.0%
Now using node v0.11.14
wscat のインストール
~/work % type npm
npm is /Users/********/.nvm/v0.11.14/bin/npm
この時点で npm
を使えるようになっているので,npm
で wscat
をインストールします.
~/work % npm install -g wscat
> ws@0.4.32 install /Users/********/.nvm/v0.11.14/lib/node_modules/wscat/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
/Users/********/.nvm/v0.11.14/bin/wscat -> /Users/********/.nvm/v0.11.14/lib/node_modules/wscat/bin/wscat
wscat@1.0.0 /Users/********/.nvm/v0.11.14/lib/node_modules/wscat
├── tinycolor@0.0.1
├── commander@2.5.1
└── ws@0.4.32 (options@0.0.6, commander@2.1.0, nan@1.0.0)
テスト
https://www.websocket.org/echo.html でテストします.
~/work % wscat -c wss:echo.websocket.org
[2K[Econnected (press CTRL+C to quit)
[1G[0J> [3Ghello world!
[1G[0J> [3G[2K[E< hello world!
大丈夫そうです.