Read the statement by Michael Teeuw here.
"Cannot find module 'valid-url'" after update
-
Just did an update to the newest version of MM (2.17.1). Made sure to reinstall everything needed, and went into each module folder to do
npm install
where needed. I got a blank screen. Fine, it’s happened before so I did some updating and troubleshooting. No dice.
Here is the warning from the output I am getting when I runnpm start dev
.[03.10.2021 16:34.46.191] [ERROR] WARNING! Could not load config file. Starting with default configuration. Error found: Error: Cannot find module 'valid-url' Require stack: - /home/pi/MagicMirror/modules/MMM-CalendarWeek/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 -
This is the only error. I am uncertain what is actually going on here. Not sure if it is telling me that these four modules have target files moved (they shouldn’t), or if there is some module it’s trying to load I don’t have installed. Or if there is a line missing in my config.
When running
npm run config:check
I get:[03.10.2021 16:35.42.348] [INFO] Checking file... /home/pi/MagicMirror/config/config.js [03.10.2021 16:35.42.461] [INFO] Your configuration file doesn't contain syntax errors :)
So…that’s fine as far as syntax.
Just need some guidance on what to do next. I’m much of a “figure it out before asking for help” kind of person. I just don’t know what
Require stack:
means, or rather how to do it or search for solutions. -
@sdetweil This worked, thank you! I had not read that far back into the changelog. There were a few others that seem to have been removed that I needed.
I am now running into another issue, maybe you can help. I wrote a cheap and dirty “module”, really it’s not, that changes my color scheme for day/night. Since updating I am getting this error in Chrome (on PC - not sure what my mirror is displaying however the function seems to be working), that I was not before:
module tries to update the DOM without being displayed.
. I get this every second - because I wrote the update interval to be that.I am not too well versed on JavaScript, but understand some basic functions - learning more by the day :)
I am not sure where this error is originating, but I think it is inmain.js
by the console logs in Chrome. I can disable this module, as it was more a project that ended up working.Here is my file for that “module”. This is it, it displays nothing.
/* Magic Mirror * Module: MMM-AutoThemes * * By Patrick Tanner * */ Module.register("MMM-AutoThemes", { // Default module config. defaults: { darkTime: "1830", lightTime: "0630", updateInterval: 1000, }, start: function () { Log.info("Starting module: " + this.name); var self = this; var dark = this.config.darkTime; var light = this.config.lightTime; Log.info("Start Dark " + dark + ' ' + "Start Light " + light); setInterval(function() { self.updateDom(); }, this.config.updateInterval); }, getDom: function autoThemes() { var h = new Date().getHours(); var m = new Date().getMinutes(); var dark = this.config.darkTime; var light = this.config.lightTime; h = h < 10 ? "0" + h : h; m = m < 10 ? "0" + m : m; var time = h + '' + m; if (dark < light) { if (time >= dark && time < light) { document.body.classList.add("dark-mode"); document.body.classList.remove("light-mode"); } else if (time < dark || time >= light) { document.body.classList.remove("dark-mode"); document.body.classList.add("light-mode"); }} else if(dark > light){ if (time >= dark || time < light) { document.body.classList.add("dark-mode"); document.body.classList.remove("light-mode"); } else if (time < dark && time >= light) { document.body.classList.remove("dark-mode"); document.body.classList.add("light-mode"); } } },
-
@pattanner92 well, getDom() is supposed to return something, and your module does not.
u don’t need to call updateDom()
just call this.autoThemes()now one other thing, every second that u are in between the time ranges, u try to remove and set the class list, even if the value to remove doesn’t exist… it would be less impact on the browser if u checked the values to remove or add
-
@sdetweil Gotcha, like I said limited knowledge with JavaScript. These changes indeed worked. Thank you!
I figured the actual function of testing whether to add or remove was heavy - if not bad practice. This was a “can I make this work?” type of thing. I will definitely rework this - since I would like to make it lighter on the browser. I don’t really know where to begin, but the internet has great resources (I’m also going to start taking some programming courses at work - I work at a University).
-
@pattanner92 get the value of the class list
and then check in your code
it’s a string containing space separated words