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.

    readFileSync

    Scheduled Pinned Locked Moved Development
    17 Posts 3 Posters 11.1k Views 1 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.
    • MichMichM Offline
      MichMich Admin
      last edited by

      What does it lockup? The fronted? Or the backend?

      If it’s just the frontend, check your webinspector/console to see what’s going on.

      M 1 Reply Last reply Reply Quote 0
      • M Offline
        mattlugar @MichMich
        last edited by

        That’s where my lack of knowledge on how to debug in this new environment was hurting me. Was able to figure out a better way to debug and now have something to work with.

        Uncaught ReferenceError: require is not defined
        

        Off to roll up my sleeves and do some mad google-fu.

        Thank you! :)

        1 Reply Last reply Reply Quote 0
        • KirAsh4K Offline
          KirAsh4 Moderator
          last edited by

          That’s because require isn’t part of JavaScript. It’s part of node.js to load modules. There are potentially other ways of doing what you’re trying to do. You may want to check out this post on Stack Overflow.

          A Life? Cool! Where can I download one of those from?

          1 Reply Last reply Reply Quote 0
          • M Offline
            mattlugar
            last edited by

            Yeah, I went about it differently than I wanted to. I ended up porting everything to an apache directory so it serves itself as a webapp. Had a few bugs to work out (it was locking up if the json was in the middle of writing when it was retrieved) but I have it working and bug free now best I can tell :)

            1 Reply Last reply Reply Quote 0
            • KirAsh4K Offline
              KirAsh4 Moderator
              last edited by

              I suppose that’s one way to do that … doesn’t make it very portable or sharable to others. It’s no longer contained within only MM and Node.js … But, if it’s working for you and does what you want, that’s the only thing that matters.

              A Life? Cool! Where can I download one of those from?

              M 1 Reply Last reply Reply Quote 0
              • MichMichM Offline
                MichMich Admin
                last edited by

                Just so you know, the node_helper can serve files as well: https://github.com/MichMich/MagicMirror/tree/master/modules#thisexpressapp

                1 Reply Last reply Reply Quote 0
                • KirAsh4K Offline
                  KirAsh4 Moderator
                  last edited by

                  I saw that when I was fiddling with some other stuff, but never actually tested it. Is that path relative to the actual module location? Or MM’s installation? Or the user that’s running MM? So if '/foo/bar/baz' is defined, where does it start?

                  /foo/bar/baz? (OH PLEASE SAY NO, for the love of all that is sacred, tell me Node.js does NOT allow system reads like that!)
                  $HOME/foo/bar/baz ?
                  $HOME/MagicMirror/foo/bar/baz?
                  $HOME/MagicMirror/modules/foo/bar/baz?
                  $HOME/MagicMirror/modules/<MODULE>/foo/bar/baz?
                  

                  A Life? Cool! Where can I download one of those from?

                  1 Reply Last reply Reply Quote 0
                  • MichMichM Offline
                    MichMich Admin
                    last edited by

                    If you are referring to this snippet:

                    start: function() {
                        this.expressApp.get('/foobar', function (req, res) {
                            res.send('GET request to /foobar');
                        });
                    }
                    

                    The /foobar is referring to the url: http://localhost:8080/foobar

                    1 Reply Last reply Reply Quote 0
                    • KirAsh4K Offline
                      KirAsh4 Moderator
                      last edited by

                      Ah, so it’s still an HTTP call then, not a simple fileread from disk.

                      A Life? Cool! Where can I download one of those from?

                      1 Reply Last reply Reply Quote 0
                      • MichMichM Offline
                        MichMich Admin
                        last edited by

                        Exactly.

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 1 / 2
                        • 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