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

TypeError: fetch is not a function #97

Closed
Robert-litts opened this issue Oct 2, 2023 · 2 comments
Closed

TypeError: fetch is not a function #97

Robert-litts opened this issue Oct 2, 2023 · 2 comments

Comments

@Robert-litts
Copy link

Good Morning,

First, I've been running MagicMirror with MMM-Wallpaper for years, for the most part flawlessly. Thanks for all of the modules you maintain!

Last night, I upgraded my MagicMirror to 2.25 and at the same time, had to upgrade my node from v16 to v20. After the upgrade, my mirror was unable to start and threw the following error:

 unhandled promise rejection warning: cannot find module 'fetch'
Require stack:
- /home/orangepi/MagicMirror/modules/MMM-Wallpaper/node_helper.js

Commenting MMM-Wallpaper out from config.js allowed the mirror to start. I then went into MagicMirror main directory and ran "npm install fetch", which ran fine. I then un-commented MMM-Wallpaper from my config and was able to run and start my mirror fine, but had no wallpaper showing up.

Reviewing my logs, I am now receiving the following errors:

0|mm  | [02.10.2023 06:14.47.203] [ERROR] Whoops! There was an uncaught exception...
0|mm  | [02.10.2023 06:14.47.242] [ERROR] TypeError: fetch is not a function
0|mm  |     at Class.request (/home/orangepi/MagicMirror/modules/MMM-Wallpaper/node_helper.js:232:5)
0|mm  |     at Class.fetchWallpapers (/home/orangepi/MagicMirror/modules/MMM-Wallpaper/node_helper.js:172:12)
0|mm  |     at Class.socketNotificationReceived (/home/orangepi/MagicMirror/modules/MMM-Wallpaper/node_helper.js:68:12)
0|mm  |     at Socket.<anonymous> (/home/orangepi/MagicMirror/js/node_helper.js:104:11)
0|mm  |     at Socket.emit (node:events:513:28)
0|mm  |     at Socket.emitUntyped (/home/orangepi/MagicMirror/node_modules/socket.io/dist/typed-events.js:69:22)
0|mm  |     at /home/orangepi/MagicMirror/node_modules/socket.io/dist/socket.js:704:39
0|mm  |     at processTicksAndRejections (node:internal/process/task_queues:77:11)
0|mm  | [02.10.2023 06:14.47.245] [ERROR] MagicMirror² will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
0|mm  | [02.10.2023 06:14.47.248] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues

Do you think this is an error with MMM-Wallpaper or with MagicMirror itself? I noticed that the release notes stated: "Replace node-fetch with internal fetch (MagicMirrorOrg/MagicMirror#2649) and remove digest-fetch", so not sure if that is related. However, the fact that I had to manually install 'fetch'

Thank you!

@apiontek
Copy link

apiontek commented Oct 2, 2023

I just encountered the same issue. The solution for me was to comment out line 11 in node_helper.js

// const fetch = require("fetch");

I only use local files myself but I tested switching to using "bing" and it gave me fetched wallpaper, so I think this could be a complete fix.

@Robert-litts
Copy link
Author

@apiontek This worked for me! Also I just pulled down the latest commit fixed the issue officially.

@kolbyjack as I stated above, this appears to be solved for me with you action. Thanks so much for the quick response and assistance!

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

No branches or pull requests

3 participants