`
lxs647
  • 浏览: 523088 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

NodeJS: express 3.0 开发过程中把user放入session小记

 
阅读更多

 这几天在小小的学习下nodejs,按照博文

http://cnodejs.org/topic/5191d30e63e9f8a542bc2758

中所记载的一步一步来运行个简单的例子。

 

当做到 session 的使用 这一小节的时候,

 

按照博文中的步骤下载session-mongoose 依赖库:

npm install session-mongoose

 

npm http GET https://registry.npmjs.org/session-mongoose
npm http 200 https://registry.npmjs.org/session-mongoose
npm http GET https://registry.npmjs.org/session-mongoose/-/session-mongoose-0.4.
1.tgz
npm http 200 https://registry.npmjs.org/session-mongoose/-/session-mongoose-0.4.
1.tgz
npm http GET https://registry.npmjs.org/mongoose
npm http 200 https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/mongoose/-/mongoose-3.8.3.tgz
npm http 200 https://registry.npmjs.org/mongoose/-/mongoose-3.8.3.tgz
npm http GET https://registry.npmjs.org/hooks/0.2.1
npm http GET https://registry.npmjs.org/mongodb/1.3.19
npm http GET https://registry.npmjs.org/sliced/0.0.5
npm http GET https://registry.npmjs.org/ms/0.1.0
npm http GET https://registry.npmjs.org/mpromise/0.3.0
npm http GET https://registry.npmjs.org/muri/0.3.1
npm http GET https://registry.npmjs.org/mpath/0.1.1
npm http GET https://registry.npmjs.org/regexp-clone/0.0.1
npm http GET https://registry.npmjs.org/mquery/0.3.2
npm http 200 https://registry.npmjs.org/sliced/0.0.5
npm http 200 https://registry.npmjs.org/ms/0.1.0
npm http 200 https://registry.npmjs.org/mpromise/0.3.0
npm http 200 https://registry.npmjs.org/muri/0.3.1
npm http 200 https://registry.npmjs.org/regexp-clone/0.0.1
npm http 200 https://registry.npmjs.org/mpath/0.1.1
npm http GET https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz
npm http GET https://registry.npmjs.org/ms/-/ms-0.1.0.tgz
npm http GET https://registry.npmjs.org/muri/-/muri-0.3.1.tgz
npm http GET https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz
npm http GET https://registry.npmjs.org/mpromise/-/mpromise-0.3.0.tgz
npm http GET https://registry.npmjs.org/mpath/-/mpath-0.1.1.tgz
npm http 200 https://registry.npmjs.org/hooks/0.2.1
npm http 200 https://registry.npmjs.org/mongodb/1.3.19
npm http 200 https://registry.npmjs.org/mquery/0.3.2
npm http GET https://registry.npmjs.org/mquery/-/mquery-0.3.2.tgz
npm http GET https://registry.npmjs.org/hooks/-/hooks-0.2.1.tgz
npm http GET https://registry.npmjs.org/mongodb/-/mongodb-1.3.19.tgz
npm http 200 https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz
npm http 200 https://registry.npmjs.org/ms/-/ms-0.1.0.tgz
npm http 200 https://registry.npmjs.org/muri/-/muri-0.3.1.tgz
npm http 200 https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz
npm http 200 https://registry.npmjs.org/mpromise/-/mpromise-0.3.0.tgz
npm http 200 https://registry.npmjs.org/mpath/-/mpath-0.1.1.tgz
npm http 200 https://registry.npmjs.org/hooks/-/hooks-0.2.1.tgz
npm http 200 https://registry.npmjs.org/mquery/-/mquery-0.3.2.tgz
npm http 200 https://registry.npmjs.org/mongodb/-/mongodb-1.3.19.tgz
npm http GET https://registry.npmjs.org/debug/0.7.0
npm http GET https://registry.npmjs.org/bson/0.2.2
npm http GET https://registry.npmjs.org/kerberos/0.0.3
npm http 200 https://registry.npmjs.org/debug/0.7.0
npm http GET https://registry.npmjs.org/debug/-/debug-0.7.0.tgz
npm http 200 https://registry.npmjs.org/bson/0.2.2
npm http 200 https://registry.npmjs.org/kerberos/0.0.3
npm http GET https://registry.npmjs.org/kerberos/-/kerberos-0.0.3.tgz
npm http GET https://registry.npmjs.org/bson/-/bson-0.2.2.tgz
npm http 200 https://registry.npmjs.org/debug/-/debug-0.7.0.tgz
npm http 200 https://registry.npmjs.org/kerberos/-/kerberos-0.0.3.tgz
npm http 200 https://registry.npmjs.org/bson/-/bson-0.2.2.tgz

> kerberos@0.0.3 install c:\sap\java\nodejs\examples\microblog\node_modules\sess
ion-mongoose\node_modules\mongoose\node_modules\mongodb\node_modules\kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)


c:\sap\java\nodejs\examples\microblog\node_modules\session-mongoose\node_modules
\mongoose\node_modules\mongodb\node_modules\kerberos>node "C:\sap\java\nodejs\no
de_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" re
build
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
 To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it
is installed elsewhere.  [c:\sap\java\nodejs\examples\microblog\node_modules\se
ssion-mongoose\node_modules\mongoose\node_modules\mongodb\node_modules\kerberos
\build\binding.sln]

> bson@0.2.2 install c:\sap\java\nodejs\examples\microblog\node_modules\session-
mongoose\node_modules\mongoose\node_modules\mongodb\node_modules\bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)


c:\sap\java\nodejs\examples\microblog\node_modules\session-mongoose\node_modules
\mongoose\node_modules\mongodb\node_modules\bson>node "C:\sap\java\nodejs\node_m
odules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuil
d
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
 To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it
is installed elsewhere.  [c:\sap\java\nodejs\examples\microblog\node_modules\se
ssion-mongoose\node_modules\mongoose\node_modules\mongodb\node_modules\bson\bui
ld\binding.sln]
npm http GET https://registry.npmjs.org/connect
npm http 200 https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/connect/-/connect-2.12.0.tgz
npm http 200 https://registry.npmjs.org/connect/-/connect-2.12.0.tgz
npm http GET https://registry.npmjs.org/batch/0.5.0
npm http GET https://registry.npmjs.org/qs/0.6.6
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/cookie-signature/1.0.1
npm http GET https://registry.npmjs.org/buffer-crc32/0.2.1
npm http GET https://registry.npmjs.org/bytes/0.2.1
npm http GET https://registry.npmjs.org/cookie/0.1.0
npm http GET https://registry.npmjs.org/send/0.1.4
npm http GET https://registry.npmjs.org/multiparty/2.2.0
npm http GET https://registry.npmjs.org/negotiator/0.3.0
npm http GET https://registry.npmjs.org/uid2/0.0.3
npm http GET https://registry.npmjs.org/fresh/0.2.0
npm http GET https://registry.npmjs.org/raw-body/1.1.2
npm http GET https://registry.npmjs.org/pause/0.0.1
npm http GET https://registry.npmjs.org/methods/0.1.0
npm http 200 https://registry.npmjs.org/qs/0.6.6
npm http 200 https://registry.npmjs.org/batch/0.5.0
npm http GET https://registry.npmjs.org/qs/-/qs-0.6.6.tgz
npm http GET https://registry.npmjs.org/batch/-/batch-0.5.0.tgz
npm http 200 https://registry.npmjs.org/cookie-signature/1.0.1
npm http 200 https://registry.npmjs.org/buffer-crc32/0.2.1
npm http 200 https://registry.npmjs.org/cookie/0.1.0
npm http 200 https://registry.npmjs.org/bytes/0.2.1
npm http 200 https://registry.npmjs.org/multiparty/2.2.0
npm http 200 https://registry.npmjs.org/send/0.1.4
npm http 200 https://registry.npmjs.org/pause/0.0.1
npm http 200 https://registry.npmjs.org/uid2/0.0.3
npm http 200 https://registry.npmjs.org/methods/0.1.0
npm http 200 https://registry.npmjs.org/raw-body/1.1.2
npm http 200 https://registry.npmjs.org/fresh/0.2.0
npm http GET https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.
1.tgz
npm http GET https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz
npm http GET https://registry.npmjs.org/bytes/-/bytes-0.2.1.tgz
npm http GET https://registry.npmjs.org/send/-/send-0.1.4.tgz
npm http GET https://registry.npmjs.org/uid2/-/uid2-0.0.3.tgz
npm http GET https://registry.npmjs.org/pause/-/pause-0.0.1.tgz
npm http GET https://registry.npmjs.org/methods/-/methods-0.1.0.tgz
npm http GET https://registry.npmjs.org/cookie/-/cookie-0.1.0.tgz
npm http GET https://registry.npmjs.org/multiparty/-/multiparty-2.2.0.tgz
npm http GET https://registry.npmjs.org/raw-body/-/raw-body-1.1.2.tgz
npm http GET https://registry.npmjs.org/fresh/-/fresh-0.2.0.tgz
npm http 200 https://registry.npmjs.org/debug
npm http 200 https://registry.npmjs.org/negotiator/0.3.0
npm http GET https://registry.npmjs.org/negotiator/-/negotiator-0.3.0.tgz
npm http 200 https://registry.npmjs.org/qs/-/qs-0.6.6.tgz
npm http 200 https://registry.npmjs.org/batch/-/batch-0.5.0.tgz
npm http 200 https://registry.npmjs.org/bytes/-/bytes-0.2.1.tgz
npm http 200 https://registry.npmjs.org/send/-/send-0.1.4.tgz
npm http 200 https://registry.npmjs.org/uid2/-/uid2-0.0.3.tgz
npm http 200 https://registry.npmjs.org/methods/-/methods-0.1.0.tgz
npm http 200 https://registry.npmjs.org/pause/-/pause-0.0.1.tgz
npm http 200 https://registry.npmjs.org/multiparty/-/multiparty-2.2.0.tgz
npm http 200 https://registry.npmjs.org/raw-body/-/raw-body-1.1.2.tgz
npm http 200 https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.
1.tgz
npm http 200 https://registry.npmjs.org/cookie/-/cookie-0.1.0.tgz
npm http 200 https://registry.npmjs.org/fresh/-/fresh-0.2.0.tgz
npm http 200 https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz
npm http 200 https://registry.npmjs.org/negotiator/-/negotiator-0.3.0.tgz
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/stream-counter
npm http GET https://registry.npmjs.org/readable-stream
npm http 200 https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http 200 https://registry.npmjs.org/mime
npm http 200 https://registry.npmjs.org/stream-counter
npm http 200 https://registry.npmjs.org/range-parser/-/range-parser-0.0.4.tgz
npm http 200 https://registry.npmjs.org/readable-stream
npm http GET https://registry.npmjs.org/core-util-is
npm http GET https://registry.npmjs.org/debuglog/0.0.2
npm http 200 https://registry.npmjs.org/core-util-is
npm http 200 https://registry.npmjs.org/debuglog/0.0.2
npm http GET https://registry.npmjs.org/debuglog/-/debuglog-0.0.2.tgz
npm http 200 https://registry.npmjs.org/debuglog/-/debuglog-0.0.2.tgz
connect@2.12.0 node_modules\connect
├── uid2@0.0.3
├── qs@0.6.6
├── debug@0.7.4
├── methods@0.1.0
├── pause@0.0.1
├── cookie-signature@1.0.1
├── fresh@0.2.0
├── raw-body@1.1.2
├── buffer-crc32@0.2.1
├── negotiator@0.3.0
├── bytes@0.2.1
├── batch@0.5.0
├── cookie@0.1.0
├── send@0.1.4 (range-parser@0.0.4, mime@1.2.11)
└── multiparty@2.2.0 (stream-counter@0.2.0, readable-stream@1.1.9)

session-mongoose@0.4.1 node_modules\session-mongoose
└── mongoose@3.8.3 (regexp-clone@0.0.1, hooks@0.2.1, sliced@0.0.5, muri@0.3.1, m
promise@0.3.0, mpath@0.1.1, ms@0.1.0, mquery@0.3.2, mongodb@1.3.19)

 在下载过程中需要build,在build的时候提示:

Could not load the Visual C++ component "VCBuild.exe"

无视之、、、

 

再重新编译运行例子的js代码,提示如下错误:

 

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [localhost:27017]
    at null.<anonymous> (c:\sap\java\nodejs\examples\microblog\node_modules\sess
ion-mongoose\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\s
erver.js:540:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (c:\sap\java\nodejs\examples\microblog\node_modules\sess
ion-mongoose\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection\c
onnection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (c:\sap\java\nodejs\examples\microblog\node_modules\se
ssion-mongoose\node_modules\mongoose\node_modules\mongodb\lib\mongodb\connection
\connection.js:478:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:441:14
    at process._tickCallback (node.js:415:13)

 搜了下发现原来是需要安装mongodb,于是转到mongodb下载页面.

由于我的开发环境是:

 

Win7 64-Bit English Version.

 

于是就按照mongodb文档 Install MongoDB on Windows 在本机进行安装。

 

安装完毕,启动mongodb:

c:\sap\java\db\mongdb>mongodb-2.4.8\bin\mongod.exe --dbpath c:\sap\java\db\mongdb\data

 完了之后再次运行express 的例子,测试运行通过。

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics