凉亭安装> TypeError:msecs必须是数字

时间:2015-08-10 16:03:22

标签: javascript node.js bower bower-install

我最近升级到node.js v0.12.7,当我想将依赖项安装到项目文件夹中时,我遇到bower install的问题:

$ bower install 
timers.js:165
    throw new TypeError('msecs must be a number');
          ^
TypeError: msecs must be a number
    at Object.exports.enroll (timers.js:165:11)
    at Socket.setTimeout (net.js:337:12)
    at ClientRequest.<anonymous> (_http_client.js:565:10)
    at ClientRequest.g (events.js:199:16)
    at ClientRequest.emit (events.js:129:20)
    at tickOnSocket (_http_client.js:493:7)
    at _http_client.js:504:7
    at process._tickCallback (node.js:355:11)

$ node --version
v0.12.7 

我发现node.js v0.12存在一些相关问题,并且此错误消息指出需要定义timeout参数的选项

所以我尝试在每个.bowerrc

的文件夹父树中添加超时
{
  "registry": "http://bower.mycompany.com",
  "timeout": "15000",
  "directory": "public/lib"
}

但它并没有像预期的那样奏效。总是抛出相同的错误。

2 个答案:

答案 0 :(得分:1)

感谢robertklep的评论,我修改了.bowerrc以匹配已定义和数字类型!&#34;超时字段。

所以我澄清了升级到node.js > v0.10后得到相同错误的人的解决方案:

如果您的项目文件夹或父文件夹树中有.bowerrc个文件,则必须使用类型为timeout的数字填充它(例如15000),如下所示:

{
  "timeout": 15000
}

答案 1 :(得分:0)

我通过传递超时作为数字而不是字符串(明确提到错误)来修复它 我在emailjs中遇到了类似的错误

timers.js:289
    throw new TypeError('"msecs" argument must be a number');
    ^
TypeError: "msecs" argument must be a number
    at Object.exports.enroll (timers.js:289:11)
    at TLSSocket.Socket.setTimeout (net.js:321:12)
    at new SMTPResponse (node_modules/emailjs/smtp/response.js:75:10)
    at Object.exports.monitor (node_modules/emailjs/smtp/response.js:80:10)
    at Object.SMTP.connect (node_modules/emailjs/smtp/smtp.js:163:33)
    at Object.Client._connect (node_modules/emailjs/smtp/client.js:78:17)
    at Object.Client._poll (node_modules/emailjs/smtp/client.js:28:18)
    at node_modules/emailjs/smtp/client.js:115:21
    at Object.Message.valid (node_modules/emailjs/smtp/message.js:180:10)
    at Object.Client.send (node_modules/emailjs/smtp/client.js:93:14)

我认为你可以使用

{
  "registry": "http://bower.mycompany.com",
  "timeout": 15000,                        //remove "
  "directory": "public/lib"
}

instad of:

{
  "registry": "http://bower.mycompany.com",
  "timeout": "15000",
  "directory": "public/lib"
}