athombv / homey-web-api-issues

This issue tracker is for Homey Developers using the Web API.
4 stars 1 forks source link

node-fetch is not a function #59

Closed ingvevs closed 1 month ago

ingvevs commented 1 month ago

When trying to create local api in node, homey.HomeyAPIV3Local.createLocalAPI, the following error message is thrown: Uncaught Error: fetch is not a function at Util.fetch (<...>.node_modules/homey-api/lib/Util.js:43:25). The node-fetch package is now an ESM-package only, thus the current require usage of it is now working any more.

https://www.npmjs.com/package/node-fetch#loading-and-configuring-the-module

robertklep commented 1 month ago

homey-api (3.6.4, aka @latest) explicitly declares node-fetch@2 as a dependency:

"dependencies": {
  ...
  "node-fetch": "^2.6.7",
  ...
}

A test script also seems to work fine for me.

ingvevs commented 1 month ago

@robertklep yes that's very strange, I verified it with a test app as well. I can't figure out why it's complaining. Perhaps it's my nextjs app setup. But then again, I see only references to @2 version of node-fetch. Closing the issue.