ZakarFin / mm-hsl-timetable

MagicMirror module for HSL timetables
MIT License
5 stars 3 forks source link

Error: Cannot find module 'request' #2

Closed pixel-lake closed 2 years ago

pixel-lake commented 2 years ago

Hey! First off, amazing that you have developed this module. Unfortunately I could not get it running, bellow is the error I am getting

Did anybody experience a similar issue? I followed your steps by git cloning the module and added the module object to config file. When I comment out the module object, magic mirror works again.

* ERROR MESSAGE BELOW*** [06.04.2022 19:09.18.238] [ERROR] App threw an error during load [06.04.2022 19:09.18.240] [ERROR] Error: Cannot find module 'request' Require stack:

ZakarFin commented 2 years ago

Thanks :)

I have this running on my mirror, but it's years since I've done a fresh install. Probably the request npm module was available through MagicMirror base dependencies but might have been removed from them since.

Looks like there's no package.json for modules. There's a chance that this could be fixed by adding "request" to https://github.com/MichMich/MagicMirror/blob/master/package.json dependencies. But there's probably a reason why it was removed so a more proper fix would be migrating away from it on my module as well.

Not promising anything, but I might take a look at this at some point :)

ilarikokko commented 2 years ago

Hi,

I have same issue as pixel-lake. Here is my errorcode:

[13.04.2022` 21:53.58.164] [ERROR] WARNING! Could not load config file. Starting with default configuration. Error found: Error: Cannot find module 'request' Require stack: - /home/magicmirror/MagicMirror/modules/mm-hsl-timetable/node_helper.js - /home/magicmirror/MagicMirror/js/app.js - /home/magicmirror/MagicMirror/js/electron.js - /home/magicmirror/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js - [13.04.2022 21:53.58.167] [ERROR] App threw an error during load [13.04.2022 21:53.58.167] [ERROR] Error: Cannot find module 'request' Require stack: - /home/magicmirror/MagicMirror/modules/mm-hsl-timetable/node_helper.js - /home/magicmirror/MagicMirror/js/app.js - /home/magicmirror/MagicMirror/js/electron.js - /home/magicmirror/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js - at Module._resolveFilename (node:internal/modules/cjs/loader:940:15) at Function.n._resolveFilename (node:electron/js2c/browser_init:249:1105) at Function.Module._resolveFilename (/home/magicmirror/MagicMirror/node_modules/module-alias/index.js:49:29) at Module._load (node:internal/modules/cjs/loader:785:27) at Function.c._load (node:electron/js2c/asar_bundle:5:13331) at Module.require (node:internal/modules/cjs/loader:1012:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. (/home/magicmirror/MagicMirror/modules/mm-hsl-timetable/node_helper.js:2:17) at Module._compile (node:internal/modules/cjs/loader:1116:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10) [13.04.2022 21:53.58.168] [ERROR] Whoops! There was an uncaught exception... [13.04.2022 21:53.58.169] [ERROR] Error: Cannot find module 'request' Require stack: - /home/magicmirror/MagicMirror/modules/mm-hsl-timetable/node_helper.js - /home/magicmirror/MagicMirror/js/app.js - /home/magicmirror/MagicMirror/js/electron.js - /home/magicmirror/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js - at Module._resolveFilename (node:internal/modules/cjs/loader:940:15) at Function.n._resolveFilename (node:electron/js2c/browser_init:249:1105) at Function.Module._resolveFilename (/home/magicmirror/MagicMirror/node_modules/module-alias/index.js:49:29) at Module._load (node:internal/modules/cjs/loader:785:27) at Function.c._load (node:electron/js2c/asar_bundle:5:13331) at Module.require (node:internal/modules/cjs/loader:1012:19) at require (node:internal/modules/cjs/helpers:102:18) at Object. (/home/magicmirror/MagicMirror/modules/mm-hsl-timetable/node_helper.js:2:17) at Module._compile (node:internal/modules/cjs/loader:1116:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1169:10) { code: 'MODULE_NOT_FOUND', requireStack: [ '/home/magicmirror/MagicMirror/modules/mm-hsl-timetable/node_helper.js', '/home/magicmirror/MagicMirror/js/app.js', '/home/magicmirror/MagicMirror/js/electron.js', '/home/magicmirror/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js', undefined ] } [13.04.2022 21:53.58.170] [ERROR] MagicMirror² will not quit, but it might be a good idea to check why this happened. Maybe no internet connection? [13.04.2022 21:53.58.170] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues

ilarikokko commented 2 years ago

Thanks :)

I have this running on my mirror, but it's years since I've done a fresh install. Probably the request npm module was available through MagicMirror base dependencies but might have been removed from them since.

Looks like there's no package.json for modules. There's a chance that this could be fixed by adding "request" to https://github.com/MichMich/MagicMirror/blob/master/package.json dependencies. But there's probably a reason why it was removed so a more proper fix would be migrating away from it on my module as well.

Not promising anything, but I might take a look at this at some point :)

I (really my friend @viljamip) got this module working with this tip! Here is how:

  1. Stop magicmirror if running.

  2. Edit package.json file with your preferred editor. You can find it in the root of magicmirror. Find "dependencies" and add request like this:

    "dependencies": {

                "colors": "^1.4.0",
                "console-stamp": "^3.0.4",
                "digest-fetch": "^1.2.1",
                "eslint": "^8.12.0",
                "express": "^4.17.3",
                "express-ipfilter": "^1.2.0",
                "feedme": "^2.0.2",
                "helmet": "^5.0.2",
                "iconv-lite": "^0.6.3",
                "luxon": "^1.21.3",
                "module-alias": "^2.2.2",
                "moment": "^2.29.2",
                "node-fetch": "^2.6.7",
                "node-ical": "^0.15.1",
                "socket.io": "^4.4.1",
                "request": "^2.88.2"                 <-----------------------------

    Save the file.

  3. Install request.

    npm install request

  4. Start magicmirror and it should work now.

It seems that request is deprecated. Here is more info about that #https://github.com/request/request/issues/3142

It also seems that magicmirror uses now Node-fetch instead.

Thank you @ZakarFin for this module!

ZakarFin commented 2 years ago

Updated the code to use node-fetch instead. Let me know if you have further issues with this.

pixel-lake commented 2 years ago

Thank you, the updated version works as intended !