TypeError:添加requirejs bower模块后无法读取未定义的属性'secure'

时间:2014-01-18 18:31:06

标签: node.js requirejs bower

我昨天在mac osx环境中测试了我的更新,但它确实有效。我提交了我的git存储库并将其拉到另一个mac osx环境中并返回此错误。我花了一些时间来尝试调试它并继续遇到同样的问题,即使我删除了一些代码以使其更简单。

我要做的是将requirejs添加到我的应用程序中,以便将javascript库捆绑在一起,从而减少下载次数。我做的是我使用凉亭安装了requirejs

$ bower ls
├──  not installed
└── requirejs#2.1.10

在网站的页脚中我将引用置于requirejs

<!-- build:js scripts/vendor/vendor.js -->
<!-- bower:js -->
  <script data-main="js/main" src="bower_components/requirejs/require.js"></script> 
<!-- endbower -->
<!-- endbuild -->   

在main.js中我引用了我的库

require(
[
"/bower_components/jquery/jquery.js",
"/js/libs/styleswitcher.js",
"/socket.io/socket.io.js",
"/js/motionCaptcha.js",
"/js/libs/underscore.js",
"/js/libs/iphone-style-checkboxes.js",
"/js/libs/jquery-ui.js",
"/js/libs/jquery.canvas-loader.1.3.js",
"/js/intlTelInput.min.js"
], 
function (jquery, styleswitcher, socket, motionCaptcha, underscore, iphone, jquery_ui, jquery_canvas, intlTelInput) {

...
[main.js javascripts here]
...

});

我不确定知道我的节点模块是否有用。节点控制台确实报告了连接错误。我删除requirejs代码时没有连接错误。以下是错误日志:

   debug - served static content /socket.io.js
TypeError: Cannot read property 'secure' of undefined
    at ServerResponse.<anonymous> (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/session.js:253:27)
    at ServerResponse.EventEmitter.emit (events.js:92:17)
    at ServerResponse.res.writeHead (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/patch.js:73:36)
    at ServerResponse.res.writeHead (/Users/jgs/Projects/lineout/node_modules/sesame/node_modules/resware/index.js:66:20)
    at ServerResponse.res.end (/Users/jgs/Projects/lineout/node_modules/sesame/node_modules/resware/index.js:50:17)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:155:13)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:192:9)
    at Forgot.middleware (/Users/jgs/Projects/lineout/node_modules/password-reset-nodemailer/index.js:90:9)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.handle (/Users/jgs/Projects/lineout/node_modules/sesame/index.js:58:9)
TypeError: Property 'resetMaxAge' of object #<Object> is not a function
    at ServerResponse.res.end (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/session.js:282:19)
    at ServerResponse.res.end (/Users/jgs/Projects/lineout/node_modules/sesame/node_modules/resware/index.js:52:14)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:149:13)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:195:7)
    at Forgot.middleware (/Users/jgs/Projects/lineout/node_modules/password-reset-nodemailer/index.js:90:9)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at Object.handle (/Users/jgs/Projects/lineout/node_modules/sesame/index.js:58:9)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at resume (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/static.js:60:7)
    at SendStream.error (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/static.js:73:37)
TypeError: Cannot read property 'secure' of undefined
    at ServerResponse.<anonymous> (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/session.js:253:27)
    at ServerResponse.EventEmitter.emit (events.js:92:17)
    at ServerResponse.res.writeHead (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/patch.js:73:36)
    at ServerResponse.res.writeHead (/Users/jgs/Projects/lineout/node_modules/sesame/node_modules/resware/index.js:66:20)
    at ServerResponse._implicitHeader (http.js:1131:8)
    at ServerResponse.OutgoingMessage.end (http.js:920:10)
    at ServerResponse.res.end (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/logger.js:148:13)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:149:13)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:195:7)
    at Object.handle (/Users/jgs/Projects/lineout/node_modules/sesame/index.js:58:9)

/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/session.js:253
        , secured = cookie.secure && tls
                          ^
TypeError: Cannot read property 'secure' of undefined
    at ServerResponse.<anonymous> (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/session.js:253:27)
    at ServerResponse.EventEmitter.emit (events.js:92:17)
    at ServerResponse.res.writeHead (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/patch.js:73:36)
    at ServerResponse.res.writeHead (/Users/jgs/Projects/lineout/node_modules/sesame/node_modules/resware/index.js:66:20)
    at ServerResponse._implicitHeader (http.js:1131:8)
    at ServerResponse.OutgoingMessage.end (http.js:920:10)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:149:13)
    at next (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/proto.js:195:7)
    at resume (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/static.js:60:7)
    at SendStream.error (/Users/jgs/Projects/lineout/node_modules/express/node_modules/connect/lib/middleware/static.js:73:37)

节点模块

├─┬ connect-mongo@0.4.0
│ └─┬ mongodb@1.3.23
│   ├── bson@0.2.5
│   └── kerberos@0.0.3
├── crypto@0.0.3
├── ejs@0.8.4
├─┬ express@3.2.4
│ ├── buffer-crc32@0.2.1
│ ├── commander@0.6.1
│ ├─┬ connect@2.7.9
│ │ ├── bytes@0.2.0
│ │ ├── formidable@1.0.13
│ │ ├── pause@0.0.1
│ │ └── qs@0.6.4
│ ├── cookie@0.0.5
│ ├── cookie-signature@1.0.1
│ ├── debug@0.7.2
│ ├── fresh@0.1.0
│ ├── methods@0.0.1
│ ├── mkdirp@0.3.4
│ ├── range-parser@0.0.4
│ └─┬ send@0.1.0
│   └── mime@1.2.6
├─┬ foursquarevenues@0.0.11
│ ├── coffee-script@1.3.3
│ └─┬ request@2.16.6
│   ├── aws-sign@0.2.0
│   ├── cookie-jar@0.2.0
│   ├── forever-agent@0.2.0
│   ├─┬ form-data@0.0.10
│   │ ├── async@0.2.9
│   │ └─┬ combined-stream@0.0.4
│   │   └── delayed-stream@0.0.5
│   ├─┬ hawk@0.10.2
│   │ ├── boom@0.3.8
│   │ ├── cryptiles@0.1.3
│   │ ├── hoek@0.7.6
│   │ └── sntp@0.1.4
│   ├── json-stringify-safe@3.0.0
│   ├── mime@1.2.11
│   ├── node-uuid@1.4.1
│   ├── oauth-sign@0.2.0
│   ├── qs@0.5.6
│   └── tunnel-agent@0.2.0
├─┬ i18n@0.4.1
│ ├── debug@0.7.4
│ └── sprintf@0.1.3
├── UNMET DEPENDENCY i18n-2 *
├── UNMET DEPENDENCY mail-notifier *
├─┬ mailer@0.6.7
│ ├── colors@0.6.2
│ └─┬ nodemailer@0.1.20
│   └── mimelib-noiconv@0.1.9
├─┬ mongodb@1.1.11
│ └── bson@0.1.5
├─┬ mongoose@3.6.11
│ ├── hooks@0.2.1
│ ├─┬ mongodb@1.3.5
│ │ ├── bson@0.1.8
│ │ └── kerberos@0.0.2
│ ├── mpath@0.1.1
│ ├─┬ mpromise@0.2.1
│ │ └── sliced@0.0.4
│ ├── ms@0.1.0
│ ├── muri@0.3.1
│ ├── regexp-clone@0.0.1
│ └── sliced@0.0.3
├── mongoose-findorcreate@0.1.2
├─┬ newrelic@1.2.0
│ ├── bunyan@0.14.6
│ └─┬ continuation-local-storage@2.6.2
│   ├─┬ async-listener@0.4.5
│   │ └── shimmer@1.0.0
│   └─┬ emitter-listener@1.0.1
│     └── shimmer@1.0.0
├─┬ nodemailer@0.6.0
│ ├── directmail@0.1.6
│ ├── he@0.3.6
│ ├─┬ mailcomposer@0.2.7
│ │ ├── dkim-signer@0.1.0
│ │ ├─┬ follow-redirects@0.0.3
│ │ │ └── underscore@1.5.2
│ │ ├── mime@1.2.9
│ │ ├─┬ mimelib@0.2.14
│ │ │ ├── addressparser@0.2.0
│ │ │ └─┬ encoding@0.1.7
│ │ │   └── iconv-lite@0.2.11
│ │ └── punycode@1.2.3
│ ├── public-address@0.1.0
│ ├─┬ readable-stream@1.1.10
│ │ ├── core-util-is@1.0.1
│ │ └── debuglog@0.0.2
│ └─┬ simplesmtp@0.3.18
│   ├── rai@0.1.9
│   └── xoauth2@0.1.8
├─┬ passport@0.1.17
│ ├── pause@0.0.1
│ └── pkginfo@0.2.3
├─┬ passport-facebook@1.0.2
│ └─┬ passport-oauth2@1.1.1
│   ├── oauth@0.9.10
│   ├── passport-strategy@1.0.0
│   └── uid2@0.0.3
├─┬ password-reset@0.1.4
│ ├── ent@0.0.7
│ └─┬ pony@0.0.2
│   ├─┬ seq@0.3.5
│   │ ├─┬ chainsaw@0.0.9
│   │ │ └── traverse@0.3.9
│   │ └─┬ hashish@0.0.4
│   │   └── traverse@0.6.6
│   └─┬ smtp-protocol@0.1.2
│     └─┬ event-stream@0.6.0
│       └─┬ optimist@0.2.8
│         └── wordwrap@0.0.2
├─┬ password-reset-nodemailer@0.0.1
│ ├── ent@0.0.7
│ └─┬ nodemailer@0.3.44
│   ├─┬ mailcomposer@0.2.7
│   │ ├── dkim-signer@0.1.0
│   │ ├─┬ follow-redirects@0.0.3
│   │ │ └── underscore@1.5.2
│   │ ├── he@0.3.6
│   │ ├── mime@1.2.9
│   │ ├─┬ mimelib@0.2.14
│   │ │ ├── addressparser@0.2.0
│   │ │ └─┬ encoding@0.1.7
│   │ │   └── iconv-lite@0.2.11
│   │ └── punycode@1.2.3
│   ├─┬ optimist@0.6.0
│   │ ├── minimist@0.0.5
│   │ └── wordwrap@0.0.2
│   └─┬ simplesmtp@0.3.18
│     ├── rai@0.1.9
│     └── xoauth2@0.1.8
├── UNMET DEPENDENCY recaptcha *
├── requirejs@2.1.10
├─┬ sesame@0.1.2
│ ├─┬ connect@2.12.0
│ │ ├── batch@0.5.0
│ │ ├── buffer-crc32@0.2.1
│ │ ├── bytes@0.2.1
│ │ ├── cookie@0.1.0
│ │ ├── cookie-signature@1.0.1
│ │ ├── debug@0.7.4
│ │ ├── fresh@0.2.0
│ │ ├── methods@0.1.0
│ │ ├─┬ multiparty@2.2.0
│ │ │ ├─┬ readable-stream@1.1.9
│ │ │ │ ├── core-util-is@1.0.1
│ │ │ │ └── debuglog@0.0.2
│ │ │ └── stream-counter@0.2.0
│ │ ├── negotiator@0.3.0
│ │ ├── pause@0.0.1
│ │ ├── qs@0.6.6
│ │ ├── raw-body@1.1.2
│ │ ├─┬ send@0.1.4
│ │ │ ├── mime@1.2.11
│ │ │ └── range-parser@0.0.4
│ │ └── uid2@0.0.3
│ ├─┬ hashish@0.0.4
│ │ └── traverse@0.6.6
│ ├─┬ node-proxy@0.7.0
│ │ └── bindings@1.1.1
│ ├── resware@0.0.4
│ └── uuid-pure@1.0.10
├─┬ socket.io@0.9.14
│ ├── base64id@0.1.0
│ ├── policyfile@0.0.4
│ ├── redis@0.7.3
│ └─┬ socket.io-client@0.9.11
│   ├─┬ active-x-obfuscator@0.0.1
│   │ └── zeparser@0.0.5
│   ├── uglify-js@1.2.5
│   ├─┬ ws@0.4.25
│   │ ├── commander@0.6.1
│   │ ├── options@0.0.5
│   │ └── tinycolor@0.0.1
│   └── xmlhttprequest@1.4.2
├─┬ stylus@0.32.1
│ ├── cssom@0.2.5
│ ├── debug@0.7.2
│ └── mkdirp@0.3.5
├─┬ twilio@1.5.0
│ ├── jwt-simple@0.1.0
│ ├── q@0.9.7
│ ├─┬ request@2.27.0
│ │ ├── aws-sign@0.3.0
│ │ ├── cookie-jar@0.3.0
│ │ ├── forever-agent@0.5.0
│ │ ├─┬ form-data@0.1.2
│ │ │ ├── async@0.2.9
│ │ │ └─┬ combined-stream@0.0.4
│ │ │   └── delayed-stream@0.0.5
│ │ ├─┬ hawk@1.0.0
│ │ │ ├── boom@0.4.2
│ │ │ ├── cryptiles@0.2.2
│ │ │ ├── hoek@0.9.1
│ │ │ └── sntp@0.2.4
│ │ ├─┬ http-signature@0.10.0
│ │ │ ├── asn1@0.1.11
│ │ │ ├── assert-plus@0.1.2
│ │ │ └── ctype@0.5.2
│ │ ├── json-stringify-safe@5.0.0
│ │ ├── mime@1.2.11
│ │ ├── node-uuid@1.4.1
│ │ ├── oauth-sign@0.3.0
│ │ ├── qs@0.6.6
│ │ └── tunnel-agent@0.3.0
│ └── underscore@1.5.2
└── validator@1.1.3

我注意到的另一件事是节点服务器是稳定的,直到我包含jquery库。如果我在页脚中添加jquery行,我会得到上面的错误。

<script src="/js/libs/public/js/libs/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>  

2 个答案:

答案 0 :(得分:0)

一个问题是socket.io是第三个依赖项,但第四个函数是arg。

答案 1 :(得分:0)

我有一个忘记密码方法,它使用芝麻进行会话。这似乎导致了这个问题。 app.use(要求( '芝麻')()); //用于会话