今日の朝練
xv6 の前に昨晩の続きを。
なんとなく微妙に gdgd だったので github から clone して、動く状態にしようとしてみます。
とりあえず、keys_file.js の左辺値を正しいものに置き換えて scp すりゃ良いのかな。これで動けば非常に嬉しいのですがどうなるか。
コピーが終わったので実行してみると
$ node app.js node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: Cannot find module 'express' at Function._resolveFilename (module.js:320:11) at Function._load (module.js:266:25) at require (module.js:348:19) at Object.<anonymous> (/home/node/tmp/getFBAuthToken/app.js:1:77) at Module._compile (module.js:404:26) at Object..js (module.js:410:10) at Module.load (module.js:336:31) at Function._load (module.js:297:12) at Array.<anonymous> (module.js:423:10) at EventEmitter._tickCallback (node.js:126:26) $
オチた。これは npm install しなきゃいかんようですな。忘れとりました。ので実行。
$ npm install oauth@0.9.5 ./node_modules/oauth express@2.5.0 ./node_modules/express ├── mkdirp@0.0.7 ├── mime@1.2.4 ├── qs@0.4.0 └── connect@1.7.3 connect-auth@0.4.1 ./node_modules/connect-auth ├── openid@0.3.1 └── connect@1.8.1 $
で、実行してみるとリスン状態になりました。
node app.js Express server listening on port 3000 in development mode
ブラウザからアクセスしてみるに css が無い風。確認してみたら昨晩 public 配下なファイルをごっそり削除してますね。BluePigment.css というソレをコピィしておきます。あとどうも画像ファイルなども必要だったようでそちらもコピィ。これで見栄えは元通りとなりました。
次は挙動の確認なんですが、facebook なボタンをポチると例外。
Error: Cannot find module 'jade' at Function._resolveFilename (module.js:320:11) at Function._load (module.js:266:25) at require (module.js:348:19) at View.templateEngine (/home/node/tmp/getFBAuthToken/node_modules/express/lib/view/view.js:134:38) at Function.compile (/home/node/tmp/getFBAuthToken/node_modules/express/lib/view.js:65:17) at ServerResponse._render (/home/node/tmp/getFBAuthToken/node_modules/express/lib/view.js:414:18) at ServerResponse.render (/home/node/tmp/getFBAuthToken/node_modules/express/lib/view.js:315:17) at /home/node/tmp/getFBAuthToken/routes/index.js:6:7 at callbacks (/home/node/tmp/getFBAuthToken/node_modules/express/lib/router/index.js:272:11) at param (/home/node/tmp/getFBAuthToken/node_modules/express/lib/router/index.js:246:11)
一応長持ちする access_token は console.log で出力されとるのですがなんでかいな、と package.json 見てみたら無い。てか昨晩削除した記憶あり。
以下に修正して
{ "name" : "fbAuth", "version" : "0.0.1", "private" : true, "dependencies" : { "express": "2.5.0" , "oauth": ">= 0.9.4" , "connect-auth": "0.4.1" , "jade": ">= 0.0.1" } }
実機に転送して npm install を。
$ npm install jade@0.18.0 ./node_modules/jade ├── mkdirp@0.2.1 └── commander@0.2.1 $
これで正常動作したのでリポジトリに反映させて再度試験を。
$ git status # On branch master # Changed but not updated: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: keys_file.js # modified: package.json # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # public/BluePigment.css # public/boxbg.jpg # public/clock.gif # public/comment.gif # public/firefox-gray.jpg # public/footer-dots.jpg # public/headerbg.jpg # public/menubg.jpg # public/nav-current.jpg # public/page.gif # public/rssfeed.gif # public/sidebarsep.jpg # public/sidebullet.gif # public/sign-in-with-twitter-d.png no changes added to commit (use "git add" and/or "git commit -a") $
ええと、keys_file.js は checkout して後は全部盛り込みで良いのかな。
$ git checkout keys_file.js $ git add . $ git commit -m '2nd fix' $ git push origin master
で、node-ninja さんで再度リポジトリを clone して実行してみます。
$ git clone git://github.com/yamanetoshi/getFBAuthToken.git Cloning into getFBAuthToken... remote: Counting objects: 32, done. remote: Compressing objects: 100% (26/26), done. remote: Total 32 (delta 4), reused 31 (delta 3) Receiving objects: 100% (32/32), 27.66 KiB, done. Resolving deltas: 100% (4/4), done. $
で、keys_file.js を修正して実行。って vi ががが状態なので scp しよ。で、npm install するんだったか。
$ npm install oauth@0.9.5 ./node_modules/oauth express@2.5.0 ./node_modules/express ├── mkdirp@0.0.7 ├── qs@0.4.0 ├── mime@1.2.4 └── connect@1.7.3 jade@0.18.0 ./node_modules/jade ├── mkdirp@0.2.1 └── commander@0.2.1 connect-auth@0.4.1 ./node_modules/connect-auth ├── openid@0.3.1 └── connect@1.8.1 $
今度は jade も入ってるので大丈夫ですな。で、これで kickoff すりゃ良いのか。
$ node app.js Express server listening on port 3000 in development mode
access token も標準出力に出力されております。