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: Cannot find module 'request' #2

Closed
pixel-lake opened this issue Apr 6, 2022 · 5 comments · Fixed by #3
Closed

Error: Cannot find module 'request' #2

pixel-lake opened this issue Apr 6, 2022 · 5 comments · Fixed by #3

Comments

@pixel-lake
Copy link

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:

  • /home/pi/MagicMirror/modules/mm-hsl-timetable/node_helper.js
  • /home/pi/MagicMirror/js/app.js
  • /home/pi/MagicMirror/js/electron.js
  • /home/pi/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/pi/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/pi/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)
    [06.04.2022 19:09.18.242] [ERROR] Whoops! There was an uncaught exception...
    [06.04.2022 19:09.18.246] [ERROR] Error: Cannot find module 'request'
    Require stack:
  • /home/pi/MagicMirror/modules/mm-hsl-timetable/node_helper.js
  • /home/pi/MagicMirror/js/app.js
  • /home/pi/MagicMirror/js/electron.js
  • /home/pi/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/pi/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/pi/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/pi/MagicMirror/modules/mm-hsl-timetable/node_helper.js',
    '/home/pi/MagicMirror/js/app.js',
    '/home/pi/MagicMirror/js/electron.js',
    '/home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js',
    undefined
    ]
@ZakarFin
Copy link
Owner

ZakarFin commented Apr 7, 2022

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
Copy link

ilarikokko commented Apr 13, 2022

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
Copy link

ilarikokko commented Apr 23, 2022

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.

  1. Install request.

npm install request

  1. Start magicmirror and it should work now.

It seems that request is deprecated. Here is more info about that #request/request#3142

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

Thank you @ZakarFin for this module!

@ZakarFin ZakarFin linked a pull request May 16, 2022 that will close this issue
@ZakarFin
Copy link
Owner

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

@pixel-lake
Copy link
Author

Thank you, the updated version works as intended !

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