3

After updating my hubot project it no longer runs on Azure. I am able to run a clean copy locally, on both OS X and Windows, but on Azure I get the following error

ERROR Cannot load adapter slack - Error: Cannot find module 'hubot'

Locally, I have node 6.9.1 and npm 3.10.9 installed. Azure is using versions 6.9.0 and 3.10.8, respectively.

Unfortunately, I haven't figured out how to collect any more information, because the node app doesn't seem to get to the point where it is producing any more detailed output.

The project and Azure website were originally created last year and started failing after I updated the npm dependencies and version of node. However, I still get the same error after reverting to node 4.x and npm 2.x or node 0.10.x or npm 1.x doesn't fix the problem.

Here is my largely unmodified hubot project that reproduces the error. The README contains the steps I took to deploy it to Azure.

Any insight would be greatly appreciated

EDIT 1

package.json

...
"dependencies": {
    "coffee-script": "^1.11.1",
    "hubot": "^2.19.0",
    "hubot-diagnostics": "0.0.1",
    "hubot-google-images": "^0.2.6",
    "hubot-google-translate": "^0.2.0",
    "hubot-help": "^0.2.0",
    "hubot-maps": "0.0.2",
    "hubot-pugme": "^0.1.0",
    "hubot-rules": "^0.1.1",
    "hubot-scripts": "^2.17.2",
    "hubot-shipit": "^0.2.0",
    "hubot-slack": "^4.2.1"
},
...

hubot is listed in my dependencies in package.json - if it weren't it wouldn't run locally. I'm aware that kudu runs npm install --production, so I made sure it was in dependencies and not devDependencies.

EDIT 2

Gary Liu - MSFT was able to shed some light on the cause and provided a workaround, but why doesn't hubot-slack: 4.+ run on Azure when it runs everywhere else?

Enrico
  • 10,377
  • 8
  • 44
  • 55
  • you have to make sure your packages.json file is updated and with all the requirements for your application to run. You could also try to install all dependencies manually using app service console. – Bruno Faria Oct 25 '16 at 16:19
  • @BrunoFaria If you mean navigating to wwwroot and running `npm install --production` from either the kudu console or azure portal console, then yes I've done that. – Enrico Oct 25 '16 at 16:32
  • did you try to specify the node version in your packages.json instead of updating through console? "engines":{"node":version} – Bruno Faria Oct 25 '16 at 16:36
  • @BrunoFaria Yes, that's how I changed the version of node and npm when I tried reverting to older version :-( – Enrico Oct 25 '16 at 17:27
  • @Enrico It works fine on my site and I can't reproduce the error message by following your steps. Would you please tell me in which step you got the error message? – Aaron Chen Oct 26 '16 at 07:59
  • @AaronChen After step 4 of the repro steps. Sometimes I have to navigate to .azurewebsites.net to get it to start up, but then the hubot never connects to Slack and I see the "cannot find module" error in my application logs – Enrico Oct 26 '16 at 13:13
  • @Enrico I get it to start up by running `.\bin\hubot` on kudu via PowerShell . Could you try that way? – Aaron Chen Oct 26 '16 at 14:54
  • @AaronChen Does it continue running if you start it that way? Will it restart automatically, if necessary? iisnode expects the start command to be `node ` or else it defaults to `node server.js` (or `node app.js`) – Enrico Oct 26 '16 at 15:55
  • I had similar problem and restarting the Web App in Azure fixed the issue. – jmu Apr 21 '17 at 15:41

2 Answers2

8

Instead of downgrading hubot-slack you can try setting below app setting and that should resolve issue

Key : NODE_PATH

Value : D:\home\site\wwwroot\node_modules

enter image description here

For some reason, hubot-slack requires global installation of hubot :(

https://github.com/slackapi/hubot-slack/issues/28

prashanth
  • 131
  • 2
  • 3
  • 11
3

I successfully reproduced your issue, and after several times testing, it seems that the issue will raise up when the dependency hubot-slack in a high version. Please try my steps.

  1. Go to App Service Editor (Preview):

    Go to Portal, select your App Service, click on App Service Editor (Preview), then click Go. enter image description here

  2. Change "hubot-slack": "^4.2.1" to "hubot-slack": "^3.4.2" in package.json.

  3. Click on console, then run the following command: npm install –production enter image description here

  4. After NPM installation, click run, you’ll make it.

enter image description here

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • Thanks! That's a good work-around, but doesn't solve the underlying problem. Why does `hubot-slack` 4.x not work on Azure when it works locally (on both OS X and Windows)? There is clearly something different about the Azure environment, but I haven't been able to figure it out. – Enrico Oct 28 '16 at 15:20
  • Between `hubot-slack` version 3.x and 4.x, they changed from `slack-client: ~1.4.0` to `@slack/client: ~3.4.0`. I wonder if the issue is the switch to a scoped dependency or something else since it was a huge jump in versions :-/ – Enrico Oct 28 '16 at 21:14
  • Letting you know I'm having the same issue as well... hopefully they can let us know about the root cause. – jmcdade Nov 20 '16 at 17:27