• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

No JavaScript experience - Config.js not working

Scheduled Pinned Locked Moved Bug Hunt
16 Posts 3 Posters 3.0k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    OlesonCrypto
    last edited by OlesonCrypto Oct 14, 2021, 4:54 PM Oct 14, 2021, 4:52 PM

    Hey guys, I’ve been running into issues the past week on this config.js file alone. I took out my some of the private links I had for obvious reasons, but I’m mostly concerned with the syntax and actually having this modules show up on my screen. I can see the Magic Mirror^2 on my Raspberry Pi monitor. When running npm run config:check I would keep getting results like: " Parsing error: Unexpected token basePath", “Parsing error: Unexpected token ipWhitelist” & “Parsing error: Unexpected token position”.

    For my setup, I’m using a monitor with the Raspberry Pi4 Model B plugged in via HDMI to MicroHDMI. I have it set up to SSH inside or use the GUI on the RP4 desktop itself. I am able to see the black Magic Mirror^2 screen, in which it asks me to “Please create a config file or check the existing one for errors”. My configuration file is located at ~/MagicMirror/config/config.js. There are no other .js files within my MagicMirror directory.

    Further Notes: I created two static IP’s for my PI: 192.168.1.101 = eth0 & 192.168.1.102 = wlan0. After modifications, I run pm2 restart 1 to restart my MagicMirror. Also I found that nano -c [File_Path] works to find the exact line and column you’re currently on as you move throughout the code.

    /* Magic Mirror Config Sample -- Edited for my project
     *
     * By Michael Teeuw https://michaelteeuw.nl
     * MIT Licensed.
     *
     * For more information on how you can configure this file
     * see https://docs.magicmirror.builders/getting-started/configuration.html#general
     * and https://docs.magicmirror.builders/modules/configuration.html
     */
    let config = {
            address: "localhost", "192.168.1.102", "192.168.1.101",  //.101=eth0, .102=wlan0
            port: 8080,
            basePath: "/",  // The URL path where MagicMirror is hosted. If you are using a Reverse proxy
                                            // you must set the sub path here. basePath must end with a /
            ipWhitelist: ["192.168.1.0/24"],  // Set [] to allow all IP addresses
            useHttps: "false", // Support HTTPS or not, default "false" will use HTTP
            //httpsPrivateKey: "",    // HTTPS private key path, only require when useHttps is true
            //httpsCertificate: "",   // HTTPS Certificate path, only require when useHttps is true
            language: "en",
            locale: "en-US",
            logLevel: ["INFO", "LOG", "WARN", "ERROR"], // Add "DEBUG" for even more logging
            timeFormat: 24,
            units: "imperial",
            // serverOnly:  true/false/"local" ,
            // local for armv6l processors, default
            //   starts serveronly and then starts chrome browser
            // false, default for all NON-armv6l devices
            // true, force serveronly mode, because you want to.. no UI on this device
    
            modules: [
                    {
                            module: "alert",
                            position:"top_left"
                    },
                    {
                            module: "updatenotification",
                            position: "top_bar"
                    },
                    {
                            module: "clock",
                            position: "top_left"
                    },
                    {
                            module: "MMM-googlecalendar"
                            position: "middle_center"
                            header: "Google Calandar"
                            config: [
                                    calendars: [
                                            {
                                                    defaultSymbol: "calendar-week"
                                                    url: "https://calendar.google.com/calendar/ical/Secret_Link_Not_Provided"
                                                    //Get link by going to Google Cal -> Settings -> Select Calendar within
                                                    //'settings for my calendars' -> *Scroll down* -> Intergrate Calendar
                                                    //Copy secret address in iCal format to url section above
                                                    maximumEntries: "14"
                                                    fetchInterval: "3600000" // Update every 60 minutes
                                                    timeFormat: "DD MMM YY"
                                             }
                                    ]
                            }
                    },
                    {
                            module: "weather",
                            position: "top_left",
                            config: {
                                    weatherProvider: "openweathermap",
                                    type: "forecast",
                                    location: "Gaithersburg, US",
                                    locationID: "4355843",
    				apiKey: "01234567890123a4567e890c1da4e678",
                                    units: "imperial",
                                    roundTemp: "true",
                                    degreeLabel: "true",
                                    updateInterval: "600000" //Updates every minute
                                    timeFormat: "24",
                                    lang: "en",
                                    showHumidity: "true",
                                    showFeelsLike: "true",
                                    showSun: "true",
                                    colored: "true"
                                    showPrecipitationAmount: "true",
                                    //maxNumberOfDays: "3" //Default=5days, max 14
                            }
                    },
            ]
    };
    
    /*************** DO NOT EDIT THE LINE BELOW ***************/
    if (typeof module !== "undefined") {module.exports = config;}
    
    S 1 Reply Last reply Oct 14, 2021, 7:46 PM Reply Quote 0
    • ? Offline
      A Former User
      last edited by Oct 14, 2021, 5:47 PM

      This post is deleted!
      O 1 Reply Last reply Oct 14, 2021, 10:24 PM Reply Quote 0
      • S Away
        sdetweil @OlesonCrypto
        last edited by Oct 14, 2021, 7:46 PM

        @olesoncrypto in the MagicMirror folder do

        npm run config:check
        

        the output will report a line number of an error

        unexpected token line 45

        well, look at line 44, and see if it should have a trailing comma (meaning more to follow)

        repeat til no error

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        O 2 Replies Last reply Oct 14, 2021, 10:27 PM Reply Quote 1
        • O Offline
          OlesonCrypto @Guest
          last edited by Oct 14, 2021, 10:24 PM

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • O Offline
            OlesonCrypto @sdetweil
            last edited by Oct 14, 2021, 10:27 PM

            @sdetweil So you’re saying delete the commas above the line where it shows I have an unexpected token line?

            O S 2 Replies Last reply Oct 14, 2021, 11:10 PM Reply Quote 0
            • O Offline
              OlesonCrypto @OlesonCrypto
              last edited by Oct 14, 2021, 11:10 PM

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • S Away
                sdetweil @OlesonCrypto
                last edited by Oct 14, 2021, 11:15 PM

                @olesoncrypto no. add. but I see u fixed it

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 1
                • O Offline
                  OlesonCrypto @sdetweil
                  last edited by Oct 14, 2021, 11:16 PM

                  @sdetweil Hey I just fixed it all up thanks you to! Adding commas a line above the syntax error fixed it. I was so happy to see “Your configuration file doesn’t contain syntax errors :)” lmao. You’re a life safer

                  S 1 Reply Last reply Oct 14, 2021, 11:18 PM Reply Quote 0
                  • S Away
                    sdetweil @OlesonCrypto
                    last edited by Oct 14, 2021, 11:18 PM

                    @olesoncrypto see my MMM-Config module. it presents a form to fill in for config.js. no more commas!!

                    https://github.com/sdetweil/MMM-Config

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    O 1 Reply Last reply Oct 15, 2021, 10:03 PM Reply Quote 0
                    • O Offline
                      OlesonCrypto @sdetweil
                      last edited by Oct 15, 2021, 10:03 PM

                      @sdetweil I have a new issue. Instead of seeing the original Magic Mirror^2 screen that says “add a config.js file or fix the syntax errors” now only shows a black screen. Both my mmstart.sh and magicmirror is active with my pm2. I also have downloaded chromium-browser. Do you know what might be the cause of this? I’ve downloaded all the module content inside of each module directory with npm.

                      S 1 Reply Last reply Oct 15, 2021, 11:24 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        1/16
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy