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.

    Cannot find module "moment"

    Scheduled Pinned Locked Moved Troubleshooting
    98 Posts 2 Posters 45.8k 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.
    • S Offline
      sdetweil @uok825
      last edited by

      @uok825 did cheerio get installed?

      cd ~/MagicMirror/modules/MMM-LICE
      ls node_modules/cheerio 
      

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      U 1 Reply Last reply Reply Quote 0
      • U Offline
        uok825 @sdetweil
        last edited by

        @sdetweil

        
        pi@raspberrypi:~ $ cd ~/MagicMirror/modules/MMM-LICE
        pi@raspberrypi:~/MagicMirror/modules/MMM-LICE $ ls node_modules/cheerio
        LICENSE  lib  package.json  Readme.md
        pi@raspberrypi:~/MagicMirror/modules/MMM-LICE $
        
        
        S 2 Replies Last reply Reply Quote 0
        • S Offline
          sdetweil @uok825
          last edited by

          @uok825 hm… I use it so it should be easy…

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @uok825
            last edited by sdetweil

            @uok825 do u need that set of parents in front of $

            ($('.....'))
            

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            U 1 Reply Last reply Reply Quote 0
            • U Offline
              uok825 @sdetweil
              last edited by

              @sdetweil Deleted parents but still same.

              0|MagicMirror  | [26.07.2021 13:25.47.639] [ERROR]
              0|MagicMirror  | Whoops! There was an uncaught exception...
              0|MagicMirror  | [26.07.2021 13:25.47.741] [ERROR]
              0|MagicMirror  | TypeError: $ is not a function
              0|MagicMirror  |     at Request.request [as _callback] (/home/pi/MagicMirror/mod                                                                                                             ules/MMM-LICE/node_helper.js:27:26)
              0|MagicMirror  |     at Request.self.callback (/home/pi/MagicMirror/modules/MMM-                                                                                                             LICE/node_modules/request/request.js:185:22)
              0|MagicMirror  |     at Request.emit (events.js:198:13)
              0|MagicMirror  |     at Request.<anonymous> (/home/pi/MagicMirror/modules/MMM-LI                                                                                                             CE/node_modules/request/request.js:1154:10)
              0|MagicMirror  |     at Request.emit (events.js:198:13)
              0|MagicMirror  |     at IncomingMessage.<anonymous> (/home/pi/MagicMirror/module                                                                                                             s/MMM-LICE/node_modules/request/request.js:1076:12)
              0|MagicMirror  |     at Object.onceWrapper (events.js:286:20)
              0|MagicMirror  |     at IncomingMessage.emit (events.js:203:15)
              0|MagicMirror  |     at endReadableNT (_stream_readable.js:1145:12)
              0|MagicMirror  |     at process._tickCallback (internal/process/next_tick.js:63:                                                                                                             19)
              0|MagicMirror  | [26.07.2021 13:25.47.770] [ERROR]
              0|MagicMirror  | MagicMirror will not quit, but it might be a good idea to check                                                                                                              why this happened. Maybe no internet connection?
              0|MagicMirror  | [26.07.2021 13:25.47.788] [ERROR] If you think this really is a                                                                                                             n issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror                                                                                                             /issues
              
              
              
              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @uok825
                last edited by sdetweil

                @uok825 weird. never seen such a thing

                can u try changing the $ to zz

                in the require and where used.

                $ is usually used for jQuery

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                U 1 Reply Last reply Reply Quote 0
                • U Offline
                  uok825 @sdetweil
                  last edited by

                  @sdetweil I just rebuild the module without using request.

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @uok825
                    last edited by

                    @uok825 ok, but THAT also make no sense…

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    U 1 Reply Last reply Reply Quote 0
                    • U Offline
                      uok825 @sdetweil
                      last edited by uok825

                      @sdetweil Hi there! Problem solved. New code:

                      /* Magic Mirror
                       * Module: MMM-LICE
                       *
                       * By Mykle1
                       *
                       */
                      const NodeHelper = require('node_helper');
                      const request = require('request');
                      const cheerio = require('cheerio');
                      
                      
                      module.exports = NodeHelper.create({
                      
                          start: function() {
                              console.log("Starting node_helper for: " + this.name);
                          },
                      
                          getLICE: function(url) {
                      		
                          request({
                              url: 'https://kur.altin.in/banka',
                              method: 'GET'
                          }, (error, response, body) => {
                      		
                              if (!error && response.statusCode == 200) {
                                  const $ = cheerio.load(body);
                      			var arr = []
                                  var result = $('.fiyat');
                                  result.each((_id,el) =>  (arr.push(el.children[0]['data'])))
                                  var result = $('h2[id=gfiy]');
                                  result.each((_id,el) =>  (arr.push(el.children[0]['data'])))
                                  this.sendSocketNotification('LICE_RESULT', arr);
                      
                              }
                      
                          });
                      },
                      
                          socketNotificationReceived: function(notification, payload) {
                              if (notification === 'GET_LICE') {
                                  this.getLICE(payload);
                              }
                          }
                      });
                      
                      

                      But i have an another problem. Turkish characters in the news seem broken. I think there is a utf-8 error but it doesn’t write anything in the logs.
                      Edit: The news site is broken, it’s not a mistake about us.

                      S 1 Reply Last reply Reply Quote 1
                      • S Offline
                        sdetweil @uok825
                        last edited by

                        @uok825 maybe u have to pass a header in the request for utf8 formated response, or encoded…

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 4
                        • 5
                        • 6
                        • 7
                        • 8
                        • 9
                        • 10
                        • 6 / 10
                        • 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