RocketChat / hubot-rocketchat

Rocket.Chat Hubot adapter
MIT License
580 stars 229 forks source link

Hubot 11 and hubot-rocketchat adapter #349

Open matdarf opened 11 months ago

matdarf commented 11 months ago

Hi,

I'm trying to get hubot and the hubot-rocketchat adapter to work together to no avail. See below for the error and the Dockerfile I'm using:

~/rc-hubot/issue$ docker run -it --rm $(docker build -q --no-cache .)
node:internal/modules/cjs/loader:1144
  const err = new Error(message);
              ^

Error: Cannot find module 'hubot/src/adapter'
Require stack:
- /usr/local/lib/node_modules/hubot/bin/hubot
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/hubot-rocketchat/index.js:3:30)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:345:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:294:7) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/local/lib/node_modules/hubot/bin/hubot' ]
}

Node.js v21.2.0
{"level":50,"time":1700829408199,"pid":8,"hostname":"796f33f944ec","name":"Hubot","msg":"Cannot load adapter /usr/local/lib/node_modules/hubot-rocketchat hubot-rocketchat - Error: Cannot find module 'hubot/src/adapter'\nRequire stack:\n- /usr/local/lib/node_modules/hubot/bin/hubot"}
~/rc-hubot/issue$ 

The below Dockerfile triggers the above error:

FROM node

WORKDIR /usr/local/lib/node_modules

RUN npm install -g hubot@11.0.0 && \
        git clone https://github.com/RocketChat/hubot-rocketchat.git

WORKDIR hubot-rocketchat

RUN npm install

ENTRYPOINT hubot -f $PWD -a rocketchat
BrunoMBento commented 4 months ago

Hi @matdarf ! I've had the same problem. It happens because hubot 11 has changed hubot package from CommonJS to ESM. I've submitted this PR today to fix this. Hope repo admins accepts it.