danielwelch / hassio-zigbee2mqtt

Hass.io add-on for zigbee2mqtt
Apache License 2.0
566 stars 189 forks source link

Error: Cannot find module './converters/common' #507

Closed dzaczek closed 3 years ago

dzaczek commented 3 years ago

zigbee2mqtt add-on version (if edge, please report commit hash): Zigbee2mqtt Current version: 1.17.0

Operating environment (HassOS, Virtual Machine, Device/platform running Home Assistant): OVM virtualmachine vmware Supervisor Version 2020.12.7 Operating System Home Assistant OS 5.10

Description of problem: Zigbee2mqrr stop working last night

Your entire configuration from the frontend (with sensitive fields redacted):

data_path: /share/zigbee2mqtt
external_converters: []
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://10.10.100.100:1883'
  user: secret
  password: secret
serial:
  port: /dev/ttyUSB0
advanced:
  log_level: info
  pan_id: 6791
  channel: 11
  network_key:
    - 1
    - 3
    - 5
    - 7
    - 9
    - 11
    - 13
    - 15
    - 0
    - 2
    - 4
    - 6
    - 8
    - 10
    - 12
    - 13
  availability_blocklist: []
  availability_passlist: []
device_options: {}
blocklist: []
passlist: []
queue: {}
frontend:
  port: 8099
experimental:
  new_api: true
  frontend: true
socat:
  enabled: false
  master: 'pty,raw,echo=0,link=/dev/ttyZ2M,mode=777'
  slave: 'tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5'
  restartdelay: 1
  initialdelay: 1
  options: '-d -d'
  log: true
zigbee_shepherd_devices: true

2021-01-04T08:15:21: PM2 log: App [npm:0] exited with code [1] via signal [SIGINT]
2021-01-04T08:15:21: PM2 log: App [npm:0] starting in -fork mode-
2021-01-04T08:15:21: PM2 log: App [npm:0] online
> zigbee2mqtt@1.17.0 start /zigbee2mqtt-1.17.0
> node index.js
internal/modules/cjs/loader.js:968
  throw err;
  ^
Error: Cannot find module './converters/common'
Require stack:
- /zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js
- /zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/index.js
- /zigbee2mqtt-1.17.0/lib/zigbee.js
- /zigbee2mqtt-1.17.0/lib/controller.js
- /zigbee2mqtt-1.17.0/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js:23:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js',
    '/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/index.js',
    '/zigbee2mqtt-1.17.0/lib/zigbee.js',
    '/zigbee2mqtt-1.17.0/lib/controller.js',
    '/zigbee2mqtt-1.17.0/index.js'
  ]
}
npm
 ERR! code ELIFECYCLE
npm
 ERR! errno 1
npm
 ERR! zigbee2mqtt@1.17.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the zigbee2mqtt@1.17.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
// replace this line with your pasted configuration
ciotlosm commented 3 years ago

Can you test out https://github.com/zigbee2mqtt/hassio-zigbee2mqtt with your config? You might get warnings if you don't remove some options (See below), but it should work.

  restartdelay: 1
  initialdelay: 1
nacbooth commented 3 years ago

I also have this exact same issue.

ciotlosm commented 3 years ago

Can you please post the logs as well?

nacbooth commented 3 years ago

Sure: Here is the log (Config will follow after that)

Zigbee2mqtt

2021-01-04T14:01:02: PM2 log: App [npm:0] starting in -fork mode-
2021-01-04T14:01:02: PM2 log: App [npm:0] online
> zigbee2mqtt@1.17.0 start /zigbee2mqtt-1.17.0
> node index.js
internal/modules/cjs/loader.js:968
  throw err;
  ^
Error: Cannot find module './converters/common'
Require stack:
- /zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js
- /zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/index.js
- /zigbee2mqtt-1.17.0/lib/zigbee.js
- /zigbee2mqtt-1.17.0/lib/controller.js
- /zigbee2mqtt-1.17.0/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js:23:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js',
    '/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/index.js',
    '/zigbee2mqtt-1.17.0/lib/zigbee.js',
    '/zigbee2mqtt-1.17.0/lib/controller.js',
    '/zigbee2mqtt-1.17.0/index.js'
  ]
}
npm

ERR!
 code ELIFECYCLE
npm ERR!
 errno 1
npm
 ERR! zigbee2mqtt@1.17.0 start: `node index.js`
npm ERR! Exit status 1
npm
 ERR! 
npm ERR! Failed at the zigbee2mqtt@1.17.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm
 ERR!     /root/.npm/_logs/2021-01-04T14_01_10_586Z-debug.log
2021-01-04T14:01:12: PM2 log: App [npm:0] exited with code [1] via signal [SIGINT]
2021-01-04T14:01:12: PM2 log: App [npm:0] starting in -fork mode-
2021-01-04T14:01:12: PM2 log: App [npm:0] online
> zigbee2mqtt@1.17.0 start /zigbee2mqtt-1.17.0
> node index.js
internal/modules/cjs/loader.js:968
  throw err;
  ^
Error: Cannot find module './converters/common'
Require stack:
- /zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js
- /zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/index.js
- /zigbee2mqtt-1.17.0/lib/zigbee.js
- /zigbee2mqtt-1.17.0/lib/controller.js
- /zigbee2mqtt-1.17.0/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js:23:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/devices.js',
    '/zigbee2mqtt-1.17.0/node_modules/zigbee-herdsman-converters/index.js',
    '/zigbee2mqtt-1.17.0/lib/zigbee.js',
    '/zigbee2mqtt-1.17.0/lib/controller.js',
    '/zigbee2mqtt-1.17.0/index.js'
  ]
}
npm
 ERR! code ELIFECYCLE
npm ERR! errno 1
npm 
ERR! zigbee2mqtt@1.17.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the zigbee2mqtt@1.17.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm
 ERR!     /root/.npm/_logs/2021-01-04T14_01_20_557Z-debug.log
2021-01-04T14:01:22: PM2 log: App [npm:0] exited with code [1] via signal [SIGINT]
2021-01-04T14:01:22: PM2 log: App [npm:0] starting in -fork mode-
2021-01-04T14:01:22: PM2 log: App [npm:0] online
> zigbee2mqtt@1.17.0 start /zigbee2mqtt-1.17.0
> node index.js

And the config:

data_path: /share/zigbee2mqtt
external_converters: []
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://mqtt.spookhollow.net'
  user: hass
  password: hass
serial:
  port: /dev/ttyACM0
  disable_led: true
advanced:
  pan_id: 6754
  channel: 11
  network_key:
    - 1
    - 3
    - 5
    - 7
    - 9
    - 11
    - 13
    - 15
    - 0
    - 2
    - 4
    - 6
    - 8
    - 10
    - 12
    - 13
  availability_blocklist: []
  availability_passlist: []
device_options: {}
blocklist: []
passlist: []
queue: {}
frontend:
  port: 8099
experimental:
  new_api: true
socat:
  enabled: false
  master: 'pty,raw,echo=0,link=/dev/ttyZ2M,mode=777'
  slave: 'tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5'
  options: '-d -d'
  log: true
  restartdelay: 1
  initialdelay: 1
zigbee_shepherd_devices: true
ciotlosm commented 3 years ago

Are you sure you tried the add-on from here: https://github.com/zigbee2mqtt/hassio-zigbee2mqtt ? Looks like you still use the old one: 2021-01-04T14:01:02: PM2 log: App [npm:0] starting in -fork mode-

New one should have an output similar to:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] socat.sh: executing... 
[14:30:09] INFO: Socat not enabled, marking service as down
[cont-init.d] socat.sh: exited 0.
[cont-init.d] zigbee2mqtt.sh: executing... 
[14:30:10] INFO: MQTT available, fetching server detail ...
[14:30:10] INFO: MQTT server settings not configured, trying to auto-discovering ...
[14:30:11] INFO: Configuring 'mqtt://core-mosquitto:1883' mqtt server
[14:30:11] INFO: MQTT credentials not configured, trying to auto-discovering ...
[14:30:11] INFO: Configuring'addons' mqtt user
[14:30:11] INFO: Previous config file found, checking backup
[14:30:11] INFO: Creating backup config in '/config/zigbee2mqtt/.configuration.yaml.bk'
[14:30:11] INFO: Adjusting Zigbee2mqtt core yaml config with add-on quirks ...
[cont-init.d] zigbee2mqtt.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[14:30:13] INFO: Handing over control to Zigbee2mqtt Core ...
> zigbee2mqtt@1.17.0 start /app
> node index.js
nacbooth commented 3 years ago

Well it looks like that might well be the case. I hadn't realised there was an alternative! I've uninstalled the add-in, removed the old repo from the "store", added the new location but installing the add-in then times out with a 504 error. I'll leave it for a little while, restart the whole system and see what happens then. I'll report back later today. Thanks for your guidance so far.

dzaczek commented 3 years ago

Are you sure you tried the add-on from here: https://github.com/zigbee2mqtt/hassio-zigbee2mqtt ? Looks like you still use the old one: 2021-01-04T14:01:02: PM2 log: App [npm:0] starting in -fork mode-

New one should have an output similar to:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] socat.sh: executing... 
[14:30:09] INFO: Socat not enabled, marking service as down
[cont-init.d] socat.sh: exited 0.
[cont-init.d] zigbee2mqtt.sh: executing... 
[14:30:10] INFO: MQTT available, fetching server detail ...
[14:30:10] INFO: MQTT server settings not configured, trying to auto-discovering ...
[14:30:11] INFO: Configuring 'mqtt://core-mosquitto:1883' mqtt server
[14:30:11] INFO: MQTT credentials not configured, trying to auto-discovering ...
[14:30:11] INFO: Configuring'addons' mqtt user
[14:30:11] INFO: Previous config file found, checking backup
[14:30:11] INFO: Creating backup config in '/config/zigbee2mqtt/.configuration.yaml.bk'
[14:30:11] INFO: Adjusting Zigbee2mqtt core yaml config with add-on quirks ...
[cont-init.d] zigbee2mqtt.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[14:30:13] INFO: Handing over control to Zigbee2mqtt Core ...
> zigbee2mqtt@1.17.0 start /app
> node index.js

You have rigt there was wrong old repo . Also for start new version from new repo i was force to remove from config line zigbee_shepherd_devices: true

ciotlosm commented 3 years ago

@dzaczek now it works? You might also have some socat config warning that you will have to fix.

Snakesms commented 3 years ago

@dzaczek now it works? You might also have some socat config warning that you will have to fix.

Faced exactly same issue today and as well realised I'm using different repo (not sure if its old, or just parallel, cause there are new versions appearing as well). - https://github.com/danielwelch/hassio-zigbee2mqtt

Once migrated to new repo - yes it does work (with default config).

If I try to run it with custom devices.js file I'm getting the error:

"[18:30:34] INFO: File devices.js found, copying to ./node_modules/zigbee-herdsman-converters/ cp: can't create './node_modules/zigbee-herdsman-converters/devices.js': No such file or directory"

with default config respective line is: "[18:31:21] WARNING: No devices.js file found in data path, starting with default devices.js"

Please kindly have a look

ciotlosm commented 3 years ago

Did you use the steps here: https://github.com/zigbee2mqtt/hassio-zigbee2mqtt/blob/master/zigbee2mqtt/DOCS.md#not-recommended-using-devicesjs-override-in-add-on to get the right devices.js ?

Also recommended version to made mods is using https://github.com/zigbee2mqtt/hassio-zigbee2mqtt/blob/master/zigbee2mqtt/DOCS.md#using-external_converters

Snakesms commented 3 years ago

Did you use the steps here: https://github.com/zigbee2mqtt/hassio-zigbee2mqtt/blob/master/zigbee2mqtt/DOCS.md#not-recommended-using-devicesjs-override-in-add-on to get the right devices.js ?

Also recommended version to made mods is using https://github.com/zigbee2mqtt/hassio-zigbee2mqtt/blob/master/zigbee2mqtt/DOCS.md#using-external_converters

Yes and it's exactly how it's done in my case: zigbee_shepherd_devices: true And the file is in the shared folder.

Regarding the recommended way: for sure I can invest some time and rebuild my approach from the UnReclmmended way to the Recommended one, but devices.js did work just fine with 1.16.2.2 and doesn't work with 1.17 so mentioned it here. Thanks

ciotlosm commented 3 years ago

@Snakesms sometimes devices.js changes structure inbetween versions, that's why you have to make sure it's the right one.

You can see here the differences between 1.16.2.2 and 1.17.0: https://github.com/Koenkk/zigbee-herdsman-converters/compare/v13.0.7...v14.0.3 for the devices.js if you search in the list

Based on your error and the file difference, I assume you didn't re-download the right devices.js as specified in the docs steps for 1.17.0 to re-modify.

Fridolin34 commented 3 years ago

Hmm... I experienced the same error like described above. This somehow happened, after I switched the channel without thinking that I would have to repair everything again. But okay, re-pairing was less effort compared to reverting everything without getting to a better connection on the new channel.

Then I got to this thread and learned that a new repository should be used. Just today I got an update announcement to 17.x - but from the old repository. So, which is the right one to use?

Then I shrugged my shoulders and removed the old addon, changed the repo URL and installed the new one. Now all 17 devices, I newly paired yesterday, are simply gone - again. Okay, so the removal of the addon deleted the entity database as well. So I paired all devices - again. Now it's working fine (even better, because the device icons got updated as well) and the next full snapshot followed instantly - and auto updates are disabled.

I'm somehow lost. What did I do wrong and where should I have seen what I could have done better? :(

nacbooth commented 3 years ago

Right, finally now have this working. Started with adding the MQTT server settings and login creds to the config file, then had to copy the devices.yaml and the database.db from the $/share/zigbee2mqtt to the new $/config/zigbee2mqtt directory structures. That took some time to realise it was needed, as although I could get the plug-in to start with the MQTT credentials, there was nothing there - and I wasn't looking forward to re-adding thirty + devices! Oh - setting the logging level to debug was what revealed the initial steps I needed to complete.
Anyway, seems OK now.

Snakesms commented 3 years ago

@Snakesms sometimes devices.js changes structure inbetween versions, that's why you have to make sure it's the right one.

You can see here the differences between 1.16.2.2 and 1.17.0: Koenkk/zigbee-herdsman-converters@v13.0.7...v14.0.3 for the devices.js if you search in the list

Based on your error and the file difference, I assume you didn't re-download the right devices.js as specified in the docs steps for 1.17.0 to re-modify.

Yes, you are right, I didn't apply modification on top of devices.js version 1.17 will try to do it tomorrow and try again. Thanks for your help