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.

    MMM-NOAA V2 doesn't start (Unexpected token < in JSON at position 0)

    Scheduled Pinned Locked Moved Unsolved Troubleshooting
    4 Posts 3 Posters 1.9k 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.
    • cruunnerrC Offline
      cruunnerr
      last edited by cruunnerr

      Hey guys,

      last time I did not let myself be seen often ^^
      But i never left u at all ;)

      Now i have a Problem and need your help guys :(

      I installed a little linux server a few months ago for managing several things. And now its time to install MM in server mode i thought.

      Lubuntu (Ubuntu 18.04.1 LTS) on x86 Hardware
      node v8.10.0
      npm v6.3.0
      MM v2.4.1

      What i did:

      • I downloaded all modules i used on my raspberry and installed them like the readme says
      • I copied my RPi config.js and used it on the linux server

      Most modules are working, but:

      MMM-NOAA and MMM-RemoteControl are giving errors -.-

      So I have several issues but lets start with NOAA ^^

      While doing npm install in the NOAA folder i get this error:

      chris@ioBroker:~/MagicMirror/modules/MMM-NOAA$ npm install
      npm WARN grunt-stylelint@0.10.0 requires a peer of stylelint@^9.0.0 but none is installed. You must install peer dependencies yourself.
      npm WARN stylelint-config-recommended@2.1.0 requires a peer of stylelint@^8.3.0 || ^9.0.0 but none is installed. You must install peer dependencies yourself.
      npm WARN stylelint-config-standard@18.2.0 requires a peer of stylelint@^8.3.0 || ^9.0.0 but none is installed. You must install peer dependencies yourself.
      
      audited 1218 packages in 12.16s
      found 1 critical severity vulnerability
        run `npm audit fix` to fix them, or `npm audit` for details
      
      
      chris@ioBroker:~/MagicMirror/modules/MMM-NOAA$ npm audit
                                                                                      
                             === npm audit security report ===                        
                                                                                      
      # Run  npm update fill-range --depth 5  to resolve 1 vulnerability
      ┌───────────────┬──────────────────────────────────────────────────────────────┐
      │ Low           │ Cryptographically Weak PRNG                                  │
      ├───────────────┼──────────────────────────────────────────────────────────────┤
      │ Package       │ randomatic                                                   │
      ├───────────────┼──────────────────────────────────────────────────────────────┤
      │ Dependency of │ stylelint [dev]                                              │
      ├───────────────┼──────────────────────────────────────────────────────────────┤
      │ Path          │ stylelint > micromatch > braces > expand-range > fill-range  │
      │               │ > randomatic                                                 │
      ├───────────────┼──────────────────────────────────────────────────────────────┤
      │ More info     │ https://nodesecurity.io/advisories/157                       │
      └───────────────┴──────────────────────────────────────────────────────────────┘
      
      
      ┌──────────────────────────────────────────────────────────────────────────────┐
      │                                Manual Review                                 │
      │            Some vulnerabilities require your attention to resolve            │
      │                                                                              │
      │         Visit https://go.npm.me/audit-guide for additional guidance          │
      └──────────────────────────────────────────────────────────────────────────────┘
      ┌───────────────┬──────────────────────────────────────────────────────────────┐
      │ Critical      │ Sandbox Breakout                                             │
      ├───────────────┼───���──────────────────────────────────────────────────────────┤
      │ Package       │ safe-eval                                                    │
      ├───────────────┼──────────────────────────────────────────────────────────────┤
      │ Patched in    │ No patch available                                           │
      ├───────────────┼──────────────────────────────────────────────────────────────┤
      │ Dependency of │ google-translate-api                                         │
      ├───────────────┼──────────────────────────────────────────────────────────────┤
      │ Path          │ google-translate-api > safe-eval                             │
      ├───────────────┼──────────────────────────────────────────────────────────────┤
      │ More info     │ https://nodesecurity.io/advisories/337                       │
      └───────────────┴──────────────────────────────────────────────────────────────┘
      found 2 vulnerabilities (1 low, 1 critical) in 1220 scanned packages
        run `npm audit fix` to fix 1 of them.
        1 vulnerability requires manual review. See the full report for details.
      
      chris@ioBroker:~/MagicMirror/modules/MMM-NOAA$ npm audit fix
      npm WARN grunt-stylelint@0.10.0 requires a peer of stylelint@^9.0.0 but none is installed. You must install peer dependencies yourself.
      npm WARN stylelint-config-recommended@2.1.0 requires a peer of stylelint@^8.3.0 || ^9.0.0 but none is installed. You must install peer dependencies yourself.
      npm WARN stylelint-config-standard@18.2.0 requires a peer of stylelint@^8.3.0 || ^9.0.0 but none is installed. You must install peer dependencies yourself.
      
      up to date in 5.181s
      fixed 0 of 1 vulnerability in 1218 scanned packages
        1 vulnerability required manual review and could not be updated
      

      Anyhow…
      When i start MM with “node server only dev” i get this:

      chris@ioBroker:~/MagicMirror$ node serveronly dev
      Starting MagicMirror: v2.4.1
      Loading config ...
      Loading module helpers ...
      No helper found for module: alert.
      Initializing new module helper ...
      Module helper loaded: MMM-TelegramBot
      Initializing new module helper ...
      Module helper loaded: MMM-WatchDog
      Initializing new module helper ...
      Module helper loaded: MMM-Remote-Control-Repository
      Initializing new module helper ...
      Module helper loaded: updatenotification
      No helper found for module: clock.
      Initializing new module helper ...
      Module helper loaded: MMM-Oiltank
      No helper found for module: MMM-EasyPix.
      Initializing new module helper ...
      Module helper loaded: MMM-NOAA
      Initializing new module helper ...
      Module helper loaded: MMM-MovieListings
      Initializing new module helper ...
      Module helper loaded: MMM-Tools
      No helper found for module: MMM-NowPlayingOnSpotify.
      Initializing new module helper ...
      Module helper loaded: MMM-CalendarExt
      Initializing new module helper ...
      Module helper loaded: MMM-MyCommute
      All module helpers loaded.
      Starting server on port 8080 ... 
      You're using a full whitelist configuration to allow for all IPs
      Server started ...
      Connecting socket for: MMM-TelegramBot
      Connecting socket for: MMM-WatchDog
      Starting module helper: MMM-WatchDog
      Connecting socket for: MMM-Remote-Control-Repository
      Connecting socket for: updatenotification
      Connecting socket for: MMM-Oiltank
      Connecting socket for: MMM-NOAA
      Starting module: MMM-NOAA
      Connecting socket for: MMM-MovieListings
      MMM-MovieListing helper started...
      Connecting socket for: MMM-Tools
      Connecting socket for: MMM-CalendarExt
      Connecting socket for: MMM-MyCommute
      ====================== Starting node_helper for module [MMM-MyCommute]
      Sockets connected & modules started ...
      
      Ready to go! Please point your browser to: http://0.0.0.0:8080
      Whoops! There was an uncaught exception...
      SyntaxError: Unexpected token < in JSON at position 0
          at JSON.parse (<anonymous>)
          at Request.request [as _callback] (/home/chris/MagicMirror/modules/MMM-NOAA/node_helper.js:77:30)
          at Request.self.callback (/home/chris/MagicMirror/node_modules/request/request.js:185:22)
          at emitTwo (events.js:126:13)
          at Request.emit (events.js:214:7)
          at Request.<anonymous> (/home/chris/MagicMirror/node_modules/request/request.js:1157:10)
          at emitOne (events.js:116:13)
          at Request.emit (events.js:211:7)
          at IncomingMessage.<anonymous> (/home/chris/MagicMirror/node_modules/request/request.js:1079:12)
          at Object.onceWrapper (events.js:313:30)
          at emitNone (events.js:111:20)
          at IncomingMessage.emit (events.js:208:7)
          at endReadableNT (_stream_readable.js:1064:12)
          at _combinedTickCallback (internal/process/next_tick.js:138:11)
          at process._tickCallback (internal/process/next_tick.js:180:9)
      MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
      If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
      

      From now on i can’t figure out whats the problem…
      Line 77 in the NOAA node_helper checks the current position and when i type “http://www.ip-api.com/json” in my browser i get a result beginning with:

      {"as":"AS3320 Deutsche Telekom AG", etc.....
      

      So why is he saying Position 0 in JSON is a SyntaxError

      Anyone have an idea?

      Thank u guys

      Edit:

      Oh ehm… here the config snippet:

      {
      			disabled: false,
      			module: 'MMM-NOAA',
      			position: 'top_left',
      			config: {
      
      				apiKey: "XXX",
      				airKey: "XXX",    // IF you want Air Quality Index
      				pws: "XXX"       
      				}
      			},
      

      And yes, i used the new API from weatherbit

      ? 1 Reply Last reply Reply Quote 0
      • ? Offline
        A Former User @cruunnerr
        last edited by A Former User

        @cruunnerr
        I’m not the creator but hope this being a help.

        request({
                    url: "http://ip-api.com/json",
                    method: 'GET'
                }, (error, response, body) => {
                         console.log(body) // Try logging suspicious point.
                         info = JSON.parse(body);
                         lat = info.lat;
                         lon = info.lon; 
                });
        

        You can get what’s wrong with this log.

        Anyway, the codes look to try to get Latitude and Longitude,
        You can set it manually like this;

        /*
        request({
                    url: "http://ip-api.com/json",
                    method: 'GET'
                }, (error, response, body) => {
                         info = JSON.parse(body);
                         lat = info.lat;
                         lon = info.lon; 
                });
        */
        lat = "50.233"; // You can get your lat & lon from https://www.latlong.net/
        lon = "8.266",
        

        And you can define this value in config and modify script with this.config.js

        1 Reply Last reply Reply Quote 1
        • cowboysdudeC Offline
          cowboysdude Module Developer
          last edited by

          If you used the new api from weatherbit then you know you don’t need the pws in the config any longer… ;)

          1 Reply Last reply Reply Quote 0
          • cruunnerrC Offline
            cruunnerr
            last edited by

            @sean said in MMM-NOAA V2 doesn't start (Unexpected token < in JSON at position 0):

            request({
            url: “http://ip-api.com/json”,
            method: ‘GET’
            }, (error, response, body) => {
            console.log(body) // Try logging suspicious point.
            info = JSON.parse(body);
            lat = info.lat;
            lon = info.lon;
            });

            OMG thank you so much…

            I am a dumbass XD
            My PiHole blocked the ip-api.com domain, so i put this to the whitelist and its running.

            Sorry guys

            1 Reply Last reply Reply Quote 1

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              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