hubot-slack在启动时抛出错误

时间:2015-12-22 23:41:36

标签: node.js hubot slack

我正在尝试为我们的Slack频道添加新的hubot集成。我在Windows机器上进行设置并部署到Heroku服务器。我按照此处提供的安装说明进行操作:https://github.com/slackhq/hubot-slack

我可以在我的本地计算机上创建并运行一个新的hubot实例(在Powershell提示符中调用" bin / hubot"但是当我安装hubot-slack软件包并添加" hubot时-slack"到external-scripts文件我收到一个错误。如果我从external-scripts文件中删除值,一切都很好。

PS C:\hubot> bin/hubot
jarvis> [Tue Dec 22 2015 15:18:24 GMT-0800 (Pacific Standard Time)] ERROR Error loading scripts from npm package - TypeError: require(...) is not a function
  at Robot.loadExternalScripts (C:\hubot\node_modules\hubot\src\robot.coffee:399:11)
  at C:\hubot\node_modules\hubot\bin\hubot:128:26
  at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)

如果我为Slack包含适配器标志,我会收到不同的错误。我尝试将HUBOT_SLACK_TOKEN设置为系统环境变量。

PS C:\hubot> bin/hubot -a slack
[Tue Dec 22 2015 15:21:54 GMT-0800 (Pacific Standard Time)] ERROR No services token provided to Hubot

我能找到的每个例子都包括对hubot的调用中的HUBOT_SLACK_TOKEN,但它对我不起作用(我必须遗漏一些东西)。

PS C:\hubot> HUBOT_SLACK_TOKEN=xoxb-22211110000-123456781234ZZZZYYYYXXXX ./bin/hubot --adapter slack
HUBOT_SLACK_TOKEN=xoxb-17240119159-dBeAEc2X8M2O9vJBYzWj5KFW : The term
'HUBOT_SLACK_TOKEN=xoxb-17240119159-dBeAEc2X8M2O9vJBYzWj5KFW' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ HUBOT_SLACK_TOKEN=xoxb-22211110000-123456781234ZZZZYYYYXXXX ./bin/hubot --adapte ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HUBOT_SLACK_TOK...234ZZZZYYYYXXXX:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

为了排除本地的内容我将应用程序部署到Heroku,但是我遇到了不同的错误。

2015-12-22T22:28:49.426496+00:00 heroku[web.1]: State changed from crashed to starting
2015-12-22T22:14:54.739959+00:00 heroku[web.1]: State changed from starting to up
2015-12-22T22:14:55.133113+00:00 app[web.1]: [Tue Dec 22 2015 22:14:55 GMT+0000 (UTC)] ERROR Error loading scripts from npm package - TypeError: object is not a function
2015-12-22T22:14:55.133117+00:00 app[web.1]:   at Robot.loadExternalScripts (/app/node_modules/hubot/src/robot.coffee:399:11, <js>:269:39)
2015-12-22T22:14:55.133119+00:00 app[web.1]:   at fs.js:272:14
2015-12-22T22:14:55.133121+00:00 app[web.1]:   at Object.oncomplete (fs.js:108:15)
2015-12-22T22:14:56.115333+00:00 heroku[web.1]: State changed from up to crashed

的package.json:

{
  "name": "jarvis",
  "version": "0.0.0",
  "private": true,
  "author": "Me <email@domain.com>",
  "description": "A friendly robot",
  "dependencies": {
    "hubot": "^2.17.0",
    "hubot-diagnostics": "0.0.1",
    "hubot-google-images": "^0.2.6",
    "hubot-google-translate": "^0.2.0",
    "hubot-help": "^0.1.2",
    "hubot-heroku-keepalive": "^1.0.1",
    "hubot-maps": "0.0.2",
    "hubot-pugme": "^0.1.0",
    "hubot-redis-brain": "0.0.3",
    "hubot-rules": "^0.1.1",
    "hubot-scripts": "^2.16.2",
    "hubot-shipit": "^0.2.0",
    "requirejs": "^2.1.22",
    "hubot-slack": "^3.4.2"
  },
  "engines": {
    "node": "0.10.x"
  }
}

外部scripts.json

[
  "hubot-diagnostics",
  "hubot-help",
  "hubot-heroku-keepalive",
  "hubot-google-images",
  "hubot-google-translate",
  "hubot-pugme",
  "hubot-maps",
  "hubot-redis-brain",
  "hubot-rules",
  "hubot-shipit",
  "requirejs",
  "hubot-slack"
]

2 个答案:

答案 0 :(得分:1)

在Windows上,似乎该机制与Linux中的处理机制略有不同。引发错误'HUBOT_SLACK_TOKEN',因为它会从windows中的环境变量中读取'HUBOT_SLACK_TOKEN'的值。

手动创建一个环境变量'HUBOT_SLACK_TOKEN'并设置该值,它将起作用。

您可以在github repo中的源代码中查看:slack.coffee。

(setenv DICTIONARY "en_US")

答案 1 :(得分:0)

引起我兴趣的是这条特殊的界限:

Error loading scripts from npm package - TypeError: require(...) is not a function

你是否从repo中添加了其他脚本?

Windows机器上的节点/ npm / coffee安装/版本可能还有问题。确保已安装这些并且版本兼容。另一个thread存在不兼容版本的问题。请告诉我们您使用的版本,并尝试将节点降级到0.12.x。

您使用令牌的方式很好。