node.jsを起動してみる

windows版をインストールすると
環境変数PATHに2つパスが追加されている。
コマンドプロンプトで確認すると
C:\Users\{ユーザ名}>echo %PATH%
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\Wind
owsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;
C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\nodejs\;C:\Use
rs\{ユーザ名}\AppData\Roaming\npm
となっているので、
C:\Users\{ユーザ名}>node
>
で、準備OK。
しかし
> node -v
ReferenceError: node is not defined
at repl:1:1
at REPLServer.defaultEval (repl.js:129:27)
at REPLServer.b [as eval] (domain.js:251:18)
at Interface.<anonymous> (repl.js:277:12)
at Interface.EventEmitter.emit (events.js:103:17)
at Interface._onLine (readline.js:194:10)
at Interface._line (readline.js:523:8)
at Interface._ttyWrite (readline.js:798:14)
at ReadStream.onkeypress (readline.js:98:10)
at ReadStream.EventEmitter.emit (events.js:106:17)
>(Ctrl+Dで終わる)
そうそう
C:\Users\{ユーザ名}>node -v
v0.11.7
C:\Users\{ユーザ名}>npm -v
1.3.8
C:\Users\{ユーザ名}>
なのだ。
さてデバッガをインストールしてみよう。

C:\Users\{ユーザ名}>npm -g install node-inspector

まだ、開発バージョンのせいだろう。
3回コマンドを繰り返えしたら成功した。
C:\Users\{ユーザ名}>npm -g install node-inspector
npm http GET https://registry.npmjs.org/node-inspector
npm http 304 https://registry.npmjs.org/node-inspector
npm http GET https://registry.npmjs.org/socket.io
npm http GET https://registry.npmjs.org/rc
npm http GET https://registry.npmjs.org/strong-data-uri
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/rc
npm http 304 https://registry.npmjs.org/socket.io
npm http 304 https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/async
npm http 304 https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/strong-data-uri
npm http GET https://registry.npmjs.org/deep-extend
npm http GET https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/ini
npm http GET https://registry.npmjs.org/truncate
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/commander/1.3.2
npm http GET https://registry.npmjs.org/connect/2.11.0
npm http GET https://registry.npmjs.org/send/0.1.4
npm http GET https://registry.npmjs.org/methods/0.1.0
npm http GET https://registry.npmjs.org/fresh/0.2.0
npm http GET https://registry.npmjs.org/buffer-crc32/0.2.1
npm http GET https://registry.npmjs.org/cookie/0.1.0
npm http GET https://registry.npmjs.org/mkdirp/0.3.5
npm http GET https://registry.npmjs.org/cookie-signature/1.0.1
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/socket.io-client/0.9.16
npm http GET https://registry.npmjs.org/policyfile/0.0.4
npm http GET https://registry.npmjs.org/base64id/0.1.0
npm http GET https://registry.npmjs.org/redis/0.7.3
npm http 304 https://registry.npmjs.org/deep-extend
npm http 304 https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/ini
npm http 304 https://registry.npmjs.org/truncate
npm http 304 https://registry.npmjs.org/cookie-signature/1.0.1
npm http 304 https://registry.npmjs.org/send/0.1.4
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/fresh/0.2.0
npm http 304 https://registry.npmjs.org/mkdirp/0.3.5
npm http 304 https://registry.npmjs.org/base64id/0.1.0
npm http 304 https://registry.npmjs.org/redis/0.7.3
npm http 304 https://registry.npmjs.org/methods/0.1.0
npm http 304 https://registry.npmjs.org/socket.io-client/0.9.16
npm http 304 https://registry.npmjs.org/connect/2.11.0
npm http 304 https://registry.npmjs.org/buffer-crc32/0.2.1
npm http 304 https://registry.npmjs.org/cookie/0.1.0
npm http 304 https://registry.npmjs.org/commander/1.3.2
npm http 304 https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/keypress
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/qs/0.6.5
npm http GET https://registry.npmjs.org/uid2/0.0.3
npm http GET https://registry.npmjs.org/bytes/0.2.1
npm http GET https://registry.npmjs.org/pause/0.0.1
npm http GET https://registry.npmjs.org/methods/0.0.1
npm http GET https://registry.npmjs.org/raw-body/0.0.3
npm http GET https://registry.npmjs.org/negotiator/0.3.0
npm http GET https://registry.npmjs.org/multiparty/2.2.0
npm http 304 https://registry.npmjs.org/policyfile/0.0.4
npm http GET https://registry.npmjs.org/uglify-js/1.2.5
npm http GET https://registry.npmjs.org/ws
npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/keypress
npm http 304 https://registry.npmjs.org/methods/0.0.1
npm http 304 https://registry.npmjs.org/bytes/0.2.1
npm http 304 https://registry.npmjs.org/uid2/0.0.3
npm http 304 https://registry.npmjs.org/negotiator/0.3.0
npm http 304 https://registry.npmjs.org/raw-body/0.0.3
npm http 304 https://registry.npmjs.org/pause/0.0.1
npm http 304 https://registry.npmjs.org/qs/0.6.5
npm http 304 https://registry.npmjs.org/multiparty/2.2.0
npm http GET https://registry.npmjs.org/readable-stream
npm http GET https://registry.npmjs.org/stream-counter
npm http 304 https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http 304 https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http 304 https://registry.npmjs.org/uglify-js/1.2.5
npm http 304 https://registry.npmjs.org/ws
npm http GET https://registry.npmjs.org/zeparser/0.0.5
npm http GET https://registry.npmjs.org/tinycolor
npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/options
npm http GET https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/readable-stream
npm http 304 https://registry.npmjs.org/stream-counter
npm http GET https://registry.npmjs.org/core-util-is
npm http GET https://registry.npmjs.org/debuglog/0.0.2
npm http 304 https://registry.npmjs.org/zeparser/0.0.5
npm http 304 https://registry.npmjs.org/nan
npm http 304 https://registry.npmjs.org/tinycolor
npm http 304 https://registry.npmjs.org/commander
npm http 304 https://registry.npmjs.org/options
> ws@0.4.31 install C:\Users\{ユーザ名}\AppData\Roaming\npm\node_modules\node-inspector\
node_modules\socket.io\node_modules\socket.io-client\node_modules\ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
C:\Users\{ユーザ名}\AppData\Roaming\npm\node_modules\node-inspector\node_modules\socket.
io\node_modules\socket.io-client\node_modules\ws>node “c:\Program Files (x86)\no
dejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp
.js” rebuild
npm http 304 https://registry.npmjs.org/debuglog/0.0.2
npm http 304 https://registry.npmjs.org/core-util-is
C:\Users\{ユーザ名}\AppData\Roaming\npm\node-inspector -> C:\Users\{ユーザ名}\AppData\Roaming\np
m\node_modules\node-inspector\bin\inspector.js
node-inspector@0.5.0 C:\Users\{ユーザ名}\AppData\Roaming\npm\node_modules\node-inspector
├── async@0.2.9
├── strong-data-uri@0.1.0 (truncate@1.0.2)
├── glob@3.2.6 (inherits@2.0.1, minimatch@0.2.12)
├── rc@0.3.1 (deep-extend@0.2.6, ini@1.1.0, optimist@0.3.7)
├── socket.io@0.9.16 (base64id@0.1.0, policyfile@0.0.4, redis@0.7.3, socket.i
o-client@0.9.16)
└── express@3.4.4 (methods@0.1.0, cookie-signature@1.0.1, fresh@0.2.0, range-
parser@0.0.4, buffer-crc32@0.2.1, cookie@0.1.0, debug@0.7.2, mkdirp@0.3.5, comma
nder@1.3.2, send@0.1.4, connect@2.11.0)
では何か動かしてみよう

C:\Users\{ユーザ名}にこんなhellow.jsを作ってみる。
var http = require('http');
var server = http.createServer(function(req, res){
   res.writeHead(200, {'Content-Type': 'text/plain'});
   res.write('Hello World\n');
   res.end();
});
server.listen(3000);
C:\Users\{ユーザ名}>node --debug hellow.js
debugger listening on port 5858
と出るので、ブラウザ(FireFox)から http://127.0.0.1:5858/ を見ると、
Type: connect
V8-Version: 3.20.17
Protocol-Version: 1
Embedding-Host: node v0.11.7
Content-Length: 0
しか出ない。
コマンドプロンプトには
GET / HTTP/1.1: (no value)
Host: 127.0.0.1:5858
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Firefo
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cache-Control: max-age=0
とログが出た。
では、デバッガを起動し、

C:\Users\{ユーザ名}>node-inspector
Node Inspector v0.5.0
info  – socket.io started
Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.

ブラウザ(FireFox)から http://127.0.0.1:8080/debug?port=5858 を見ると、

node.jsのデバッガ画面
node.jsのデバッガ画面



とソレっぽい画面は出てくるものの何も出ない。(大笑
とりあえず、IDEっぽいものは既にあるようだ。
説明ページもあったが、
Windowsではまだまだのようだ。
デバッガが
lob error { [Error: EPERM, readdir ‘C:\Users\{ユーザ名}\AppData\Local\Microsoft\Windows
INetCache\Content.IE5’]
errno: -4049,
code: ‘EPERM’,
と延々とパスをサーチしてしまう。
次はCentOS6でやってみよう。
 
 




コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA