patrickkfkan / volumio-now-playing

17 stars 4 forks source link

Stack trace: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module #15

Closed ValentinMumble closed 11 hours ago

ValentinMumble commented 2 days ago

Hello, First, thanks for this plugin. But unfortunately I struggle to enable it on my freshly installed Volumio (v3.779) on a Raspberry Pi 3+ The installation works fine but each time I try to enable it, I get this error in the logs and Volumio starts crashing until I remove the plugin folder... Does this ring a bell to anyone? Thanks!

Nov 30 17:09:36 volumio volumio[9476]: info: Enabling plugin now_playing
Nov 30 17:09:36 volumio volumio[9476]: info: Loading plugin "now_playing"...
Nov 30 17:09:36 volumio volumio[9476]: error: !!!! WARNING !!!!
Nov 30 17:09:36 volumio volumio[9476]: error: The plugin user_interface/now_playing failed to load, setting it to stopped. Error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /data/plugins/user_interface/now_playing/node_modules/point-in-polygon-hao/dist/pointInPolygon.mjs
Nov 30 17:09:36 volumio volumio[9476]: error: Stack trace: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /data/plugins/user_interface/now_playing/node_modules/point-in-polygon-hao/dist/pointInPolygon.mjs
Nov 30 17:09:36 volumio volumio[9476]:     at Module.load (internal/modules/cjs/loader.js:926:11)
Nov 30 17:09:36 volumio volumio[9476]:     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
Nov 30 17:09:36 volumio volumio[9476]:     at Module.require (internal/modules/cjs/loader.js:952:19)
Nov 30 17:09:36 volumio volumio[9476]:     at require (internal/modules/cjs/helpers.js:88:18)
Nov 30 17:09:36 volumio volumio[9476]:     at Object.<anonymous> (/data/plugins/user_interface/now_playing/node_modules/@turf/boolean-point-in-polygon/dist/cjs/index.cjs:2:26)
Nov 30 17:09:36 volumio volumio[9476]:     at Module._compile (internal/modules/cjs/loader.js:1063:30)
Nov 30 17:09:36 volumio volumio[9476]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
Nov 30 17:09:36 volumio volumio[9476]:     at Module.load (internal/modules/cjs/loader.js:928:32)
Nov 30 17:09:36 volumio volumio[9476]:     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
Nov 30 17:09:36 volumio volumio[9476]:     at Module.require (internal/modules/cjs/loader.js:952:19)
Nov 30 17:09:36 volumio volumio[9476]: error: !!!! WARNING !!!!
Nov 30 17:09:36 volumio volumio[9476]: info: Error: TypeError: Cannot read property 'printToastMessage' of null
patrickkfkan commented 2 days ago

Appears that a dependency was published two days ago with a minor version upgrade that led to this issue. That upgrade shouldn't have been marked as minor as it contains breaking changes. Anyway, will see if I can resolve this soon.

ValentinMumble commented 1 day ago

Thanks for the info! In the meantime, would it be possible to fix the dependency to a previous version in the package.json maybe?

patrickkfkan commented 1 day ago

Yes, you could do:

$ cd /data/plugins/user_interface/now_playing/
$ npm i point-in-polygon-hao@1.1.0 --production
$ systemctl restart volumio
patrickkfkan commented 1 day ago

The issue is being tracked here:

https://github.com/rowanwins/point-in-polygon-hao/issues/20

If it's resolved there, then all is good and nothing needs to be done other than reinstalling the plugin.

grahamsingle commented 1 day ago

Thanks, the workaround worked. UI came back up as soon as I ran npm as it was constantly restarting. Very much appreciate your help.,