Read the statement by Michael Teeuw here.
Getting an error when trying to implement MMM-Cursor into my config.js file
-
Hi guys,
I’m pretty new to the raspberry pi scene as well as the MM scene. I’ve successfully installed the MM and a touch screen module for whenever I eventually get a screen that has touch screen. In the meantime though, I am trying to install a cursor module and I’m running into some trouble.
I’m using this code:
https://github.com/uxigene/MMM-Cursor
In the terminal, everything works fine and dandy but when I paste:
modules: [ { module: 'MMM-Cursor', config: { // See 'Configuration options' for more information. } } ]
into my config.js file, I’m running into an error that reads in my terminal:
nateb827@raspberrypi:~/MagicMirror $ npm run config:check > magicmirror@2.20.0 config:check > node js/check_config.js [INFO] Checking file... /home/nateb827/MagicMirror/config/config.js [ERROR] Your configuration file contains syntax errors :( [ERROR] Line 115 column 1: Parsing error: Unexpected token modules
and here is the code, directly copied and pasted from the site into my config.js file
(the first line is 115, “modules: [”)modules: [ { module: 'MMM-Cursor', config: { // See 'Configuration options' for more information. } } ] ] };
I’ve tried deleting the “modules” and the brackets surrounding so it just has the “module”, and not “modules” like my other module but to no avail. I’ve tried putting it outside of my main magic mirror code and it runs with no syntax but no cursor either. I’ve been stuck on this for a few days now and I haven’t seen a lot on online surrounding this issue so any help would be greatly appreciated.
-
hi @nateb827
You might’ve just mangled the config.js file a bit is all - perhaps the sample config entry includes some brackets that you didn’t need in your case?
If you take a look in your config.js file in your text editor -ideally something like Notepad++ if you can but there are many options - you just want an editor that will be more helpful than plain Windows Notepad. Scroll down to the modules: [ section.
Here’s an example from the top of mine (just an edited chunk, to illustrate …
modules: [ { module: "alert", }, { module: "updatenotification", position: "top_bar" }, { module: "clock", position: "top_left" } ]
So the modules: section as a whole is contained between square brackets [ and ] as you can hopefully see - the opening [ comes immediately after modules: and the closing one ] comes at the end of the list.
Inbetween those, the modules themselves are specified between curly brackets { and }. Entries for the modules have commas between them. Modules with detailed configuration options have those specified within further pairs of { and } nested inside the entry for the module - MMM-Cursor includes a config {} entry as an example of this.To add your new module to the config.js file you just need to make sure you follow this pattern when pasting the entry in.
I’m assuming you’re adding the entry into the existing modules: section in your config.js, so you don’t need themodules: [
or the last ] provided in the Using the module example on the github page, just the entry for the module itself:
{ module: "MMM-Cursor", config: { // See 'Configuration options' for more information. } },
It’s easy to drag in unwanted or unpaired brackets when you copy/paste though, and this might break your config. Some text editors will flag unpaired brackets that have made the overall .js file invalid, which can be helpful as you’re making changes.
Using the example above, I’ve pasted an entry for the MMM-Cursor module in between the entries for the updatenotification and clock modules so you can see what it looks like.
modules: [ { module: "alert", }, { module: "updatenotification", position: "top_bar" }, { module: "MMM-Cursor", config: { // See 'Configuration options' for more information. } }, { module: "clock", position: "top_left" } ]
If you wanted to paste your new entry at the end of the modules: list (after clock in this example) the only difference would be to add a comma at the closing } for the clock module (and remove any trailing comma at the closing } of your new entry) i.e.
{ module: "clock", position: "top_left" }, { module: "MMM-Cursor", config: { // See 'Configuration options' for more information. } } ]
Hope this helps, apologies if I’ve gone into too much detail about stuff you already know. If you still don’t have any luck maybe try pasting your whole modules section from your config.js and someone can take a look?
-
@nateb827 Hi. Have you try only this?
{ module: "MMM-Cursor", config: { // See 'Configuration options' for more information. } }
If it does not work with this config try adding a comma at the third bracket like this
{ module: "MMM-Cursor", config: { // See 'Configuration options' for more information. }, }
-
@Anthony extra trailing commas are allowed but useless
-
hi @nateb827
You might’ve just mangled the config.js file a bit is all - perhaps the sample config entry includes some brackets that you didn’t need in your case?
If you take a look in your config.js file in your text editor -ideally something like Notepad++ if you can but there are many options - you just want an editor that will be more helpful than plain Windows Notepad. Scroll down to the modules: [ section.
Here’s an example from the top of mine (just an edited chunk, to illustrate …
modules: [ { module: "alert", }, { module: "updatenotification", position: "top_bar" }, { module: "clock", position: "top_left" } ]
So the modules: section as a whole is contained between square brackets [ and ] as you can hopefully see - the opening [ comes immediately after modules: and the closing one ] comes at the end of the list.
Inbetween those, the modules themselves are specified between curly brackets { and }. Entries for the modules have commas between them. Modules with detailed configuration options have those specified within further pairs of { and } nested inside the entry for the module - MMM-Cursor includes a config {} entry as an example of this.To add your new module to the config.js file you just need to make sure you follow this pattern when pasting the entry in.
I’m assuming you’re adding the entry into the existing modules: section in your config.js, so you don’t need themodules: [
or the last ] provided in the Using the module example on the github page, just the entry for the module itself:
{ module: "MMM-Cursor", config: { // See 'Configuration options' for more information. } },
It’s easy to drag in unwanted or unpaired brackets when you copy/paste though, and this might break your config. Some text editors will flag unpaired brackets that have made the overall .js file invalid, which can be helpful as you’re making changes.
Using the example above, I’ve pasted an entry for the MMM-Cursor module in between the entries for the updatenotification and clock modules so you can see what it looks like.
modules: [ { module: "alert", }, { module: "updatenotification", position: "top_bar" }, { module: "MMM-Cursor", config: { // See 'Configuration options' for more information. } }, { module: "clock", position: "top_left" } ]
If you wanted to paste your new entry at the end of the modules: list (after clock in this example) the only difference would be to add a comma at the closing } for the clock module (and remove any trailing comma at the closing } of your new entry) i.e.
{ module: "clock", position: "top_left" }, { module: "MMM-Cursor", config: { // See 'Configuration options' for more information. } } ]
Hope this helps, apologies if I’ve gone into too much detail about stuff you already know. If you still don’t have any luck maybe try pasting your whole modules section from your config.js and someone can take a look?
-
@raymondjspigot This worked beautifully. I cannot tell you how much trial and error you’ve just solved for me. Blessings
-
@nateb827 hiya, thanks for the note to say you’d got it sorted! No worries, best wishes for your future configurating : )