MagicMirror: New version of magicmirror does not work in docker

Hello,

I am getting this issue when I am trying to launch the latest version of docker:

[22.07.2021 12:16.03.454] [LOG]   Starting MagicMirror: v2.16.0
[22.07.2021 12:16.03.462] [LOG]   Loading config ...
[22.07.2021 12:16.03.474] [LOG]   Loading module helpers ...
[22.07.2021 12:16.03.497] [ERROR] WARNING! Could not load config file. Starting with default configuration. Error found: Error: Cannot find module 'request'
Require stack:
- /opt/magic_mirror/modules/MMM-quote-of-the-day/node_helper.js
- /opt/magic_mirror/js/app.js
- /opt/magic_mirror/serveronly/index.js
[22.07.2021 12:16.03.499] [LOG]   Loading module helpers ...
[22.07.2021 12:16.03.504] [ERROR] Whoops! There was an uncaught exception...
[22.07.2021 12:16.03.514] [ERROR] Error: Cannot find module 'request'
Require stack:
- /opt/magic_mirror/modules/MMM-quote-of-the-day/node_helper.js
- /opt/magic_mirror/js/app.js
- /opt/magic_mirror/serveronly/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._resolveFilename (/opt/magic_mirror/node_modules/module-alias/index.js:49:29)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/opt/magic_mirror/modules/MMM-quote-of-the-day/node_helper.js:2:17)
    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)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/opt/magic_mirror/modules/MMM-quote-of-the-day/node_helper.js',
    '/opt/magic_mirror/js/app.js',
    '/opt/magic_mirror/serveronly/index.js'
  ]
}
[22.07.2021 12:16.03.515] [ERROR] MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
[22.07.2021 12:16.03.516] [ERROR] If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues

Can you please advise me what I am doing wrong? v2.15 is working fine.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 36 (4 by maintainers)

Most upvoted comments

Better solution than changing the docker is to send a PR to the problematic modules to fix the issue and use your own fork in the meantime.

this is because the request module was removed in 2.16 because of deprecation. and some of the other library files that used it.

See this content from discord mm support channel

in the docs https://khassel.gitlab.io/magicmirror/configuration/ you find a way how to log in into the running container. The key is docker exec -it mm bash, with this command you are in the container and navigate to the module folder and in the module folder you can install the missing packages with npm install xy

Great to hear. No that you have a fork anyway, it might be worth sending a pull request to the original repos. That way other can benefit from your contribution.

@theskyisthelimit so now we come closer why it was not persistent, checked it in my environment.

If such a module e.g. MMM-Sonos comes without a package.json file the workaround with “install request in the module folder” does not work. I found the installed request package after this installation in the node_modules folder of mm and not under the module folder.

In this case you have to execute npm init and then npm install request (both in the module folder).

If there are so many modules still depending on the request module, I have no problem adding it back again as a npm dependency. What do you think, @khassel?

Another (maybe simpler) workaround ist to change (temporarily) the command section in the docker-compose.yml from

    command: 
      - npm
      - run
      - server

to

    command: 
      - sleep
      - infinity

To be clear where to install request: Not in the main folder of mm but in every module folder where it is missing, so e.g. in the first post here it was missing in modules/MMM-quote-of-the-day so you have to cd into this folder an run npm install request there.

If you run it in the main folder it will not survive a container restart.

You have to do this only once (for every module where it is missing) until a new version of a module is released (where its may fixed because this is a problem of the module).

The problem is that you can’t exec into the container because the container always restarts because of the request errors.

To solve this you have to do this with a working config. You can disable the modules in your config which are causing the errors or you can use the default config for this.