Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR LOADING PLUGIN homebridge-bomgovau #12

Closed
shannondpasto opened this issue Oct 15, 2021 · 5 comments · Fixed by #13
Closed

ERROR LOADING PLUGIN homebridge-bomgovau #12

shannondpasto opened this issue Oct 15, 2021 · 5 comments · Fixed by #13

Comments

@shannondpasto
Copy link

Hi.
Recently installed this plugin but it's not loading causing the line No plugin was found for the accessory "BOMgovau" in your config.json. Please make sure the corresponding plugin is installed correctly. to show up in the log. Digging a bit deeper the following also appears in the log...

[15/10/2021, 9:39:44 pm] ====================
[15/10/2021, 9:39:44 pm] ERROR LOADING PLUGIN homebridge-bomgovau:
[15/10/2021, 9:39:44 pm] Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /usr/lib/node_modules/homebridge-bomgovau/node_modules/node-fetch/src/index.js
require() of ES modules is not supported.
require() of /usr/lib/node_modules/homebridge-bomgovau/node_modules/node-fetch/src/index.js from /usr/lib/node_modules/homebridge-bomgovau/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /usr/lib/node_modules/homebridge-bomgovau/node_modules/node-fetch/src/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /usr/lib/node_modules/homebridge-bomgovau/node_modules/node-fetch/package.json.

    at new NodeError (internal/errors.js:322:7)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/usr/lib/node_modules/homebridge-bomgovau/index.js:9:13)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
[15/10/2021, 9:39:44 pm] ====================

Installed versions
Homebridge v1.3.5
Node.js v14.18.0
Npm 6.14.15

Thanks,
Shannon

@mitch7391
Copy link
Contributor

Oh I just submitted this as a question on reddit and was pointed in the right direction by another developer. @SteveCohen apparently the issue is with node-fetch

"dependencies": {
    "node-fetch":">=1.0",
    "fakegato-history": ">0.4.0",
    "hap-nodejs-community-types": "https://github.com/homespun/hap-nodejs-community-types.git"
    }

I was advised you should be using ^ instead of >= and the version should be taken to 2.6.6; so all up should be changed to "node-fetch":"^2.6.6". I have just created a PR for it if you want to take a look Steve (and make sure I did not do it wrong)?

@SteveCohen
Copy link
Owner

SteveCohen commented Dec 20, 2021

Thanks Mitch, that's interesting. I'm learning here too!

I read the reddit thread. Judging by Western_Icy's comment ("esm modules and currently incompatible with homebridge") it sounds like >=1.0 doens't work because it's installing a module that's too new, and not compatible with Homebridge? I'll clarify on Reddit.

Quick question in the meantime. Did you test the PR and confirm it works?

@mitch7391
Copy link
Contributor

mitch7391 commented Dec 20, 2021

Hey Steve :) yep definitely still learning myself and only just published my first npm package recently to make my repo available on Homebridge UI.

I actually thought it was the other way around; but I could be wrong! But actually now that I think about it more; based on the ‘>=‘ it should mean that as long as the version is greater than or equal to the designated value then it should be fine. However, I do not understand what the difference is by using ‘^’ but have noted a lot of plugins I am using are using that method in their package.json dependencies.

I tried to install my fork of your repo through ‘git clone’, ‘npm pack’ and install (something Iv only recently learned to do) for testing but it would not let me install it. Which means I have not been able to test it myself and suggest you test it yourself before approving the PR. I did do the exact same thing for a second plug-in with the exact same ‘node-fetch’ issue; it let me install the fork locally and it worked perfectly. Not sure why your plug-in won’t let me try.

@mitch7391
Copy link
Contributor

Hey @SteveCohen, I tired to install my fork of your repo locally and it still will not let me due to NPM error 128; will have to look into it properly later. I am certain it is an issue with my local install of your plugin and not an issue with the changes I have made. Based on the comments from Reddit and the readings you linked there; it looks like the change is required and I will be looking forward to getting this plugin installed again. So would we be good to merge the changes and publish; or is there anything else we need to test first?

@SteveCohen
Copy link
Owner

Thanks Mitch,
The change looks simple, but as you've not been able to install your fork on your own system successfully, I am reluctant to accept the PR. I'm unable to test it myself at the moment as I'm travelling over christmas. And once it's accepted I'll also need to push it to NPM -- again, something I can do when i'm home.

Will look at this again when I'm back at home in January. Thanks for investigating it and submitting the PR, in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants