2012年8月18日土曜日

☆500 Error: Cannot find module 'ejs'



$ node app.js
Express server listening on port 3000
Error: Cannot find module 'ejs'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at new View (/Users/Junichi/node_modules/express/lib/view.js:42:49)
    at Function.app.render (/Users/Junichi/node_modules/express/lib/application.js:486:12)
    at ServerResponse.res.render (/Users/Junichi/node_modules/express/lib/response.js:677:7)
    at exports.index (/Users/Junichi/node/routes/index.js:7:7)
    at callbacks (/Users/Junichi/node_modules/express/lib/router/index.js:165:11)
    at param (/Users/Junichi/node_modules/express/lib/router/index.js:139:11)

とのことで


hmm it kinda looks like it's using a globally installed express..(https://github.com/visionmedia/express/issues/910)

からの

sudo npm install -g express

/usr/local/bin/express -> /usr/local/lib/node_modules/express/bin/express

node app.js

500 Error: Cannot find module 'ejs'

・・・( ゚д゚)ハア!?

ちなみに、
ecpress --versiion →3.0.0rc3
node -v →v0.8.5

というか、express、グローバルに入れてからアプリケーションの作成してないよね
で、アプリ作成したかったけどコマンド忘れたから作り方見ようとネットを探してると・・・
「ls node_module」というコマンドを発見
↓打ってみる
$ ls node_modules/
ejs socket.io twitter-node
・・・ejsあるけど、expressないやん。
npm install express
$ ls node_modules/
ejs express socket.io twitter-node
ほいさ。
からの
JK:node Junichi$ express -t ejs test

   create : test
   create : test/package.json
   create : test/app.js
   create : test/public
   create : test/public/javascripts
   create : test/public/images
   create : test/public/stylesheets
   create : test/public/stylesheets/style.css
   create : test/routes
   create : test/routes/index.js
   create : test/views
   create : test/views/layout.jade
   create : test/views/index.jade

   install dependencies:
     $ cd test && npm install

   run the app:
     $ node app
(・・・jade入ってるし・・・)
とりあえずweb開いてみる

500 Error: Cannot find module 'jade'

  • at Function.Module._resolveFilename (module.js:338:15)
  • at Function.Module._load (module.js:280:25)
  • at Module.require (module.js:362:17)
  • at require (module.js:378:17)
  • at new View (/Users/Junichi/node/node_modules/express/lib/view.js:42:49)
  • at Function.app.render (/Users/Junichi/node/node_modules/express/lib/application.js:486:12)
  • at ServerResponse.res.render (/Users/Junichi/node/node_modules/express/lib/response.js:677:7)
  • at exports.index (/Users/Junichi/node/test/routes/index.js:7:7)
  • at callbacks (/Users/Junichi/node/node_modules/express/lib/router/index.js:165:11)
  • at param (/Users/Junichi/node/node_modules/express/lib/router/index.js:139:11)
・・・んだ。
とりあえず、ejsで入るように入れ直して見る。
$ express -tejs test

   create : test
   create : test/package.json
   create : test/app.js
   create : test/public
   create : test/public/javascripts
   create : test/public/images
   create : test/public/stylesheets
   create : test/public/stylesheets/style.css
   create : test/routes
   create : test/routes/index.js
   create : test/views
   create : test/views/index.ejs

   install dependencies:
     $ cd test && npm install

   run the app:
     $ node app
localhost:3000
キタ━━━━(゚∀゚)━━━━!!

<hr>
【結果と考察】
500 Error: Cannot find module 'ejs'は、
グローバルに入ってない系。
で、グローバルに入れ直したらアプリケーション、作りなおして下しあ。



0 件のコメント:

コメントを投稿