5 Replies Latest reply on Nov 10, 2014 6:30 AM by Intel_Alvarado

    Cannot find module 'utf8'...

    Arnold007

      Hi!

       

      When I launch my Intel Express server.socket.js sketch on my Galileo Gen 1, I get the following message :

       

      root@clanton:~/tinyWebServer# node server_socket.js

       

      module.js:340

          throw err;

                ^

      Error: Cannot find module 'utf8'

          at Function.Module._resolveFilename (module.js:338:15)

          at Function.Module._load (module.js:280:25)

          at Module.require (module.js:362:17)

          at require (module.js:378:17)

          at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/engine.io/node_modules/engine.io-parser/lib/index.js:5:12)

          at Module._compile (module.js:449:26)

          at Object.Module._extensions..js (module.js:467:10)

          at Module.load (module.js:356:32)

          at Function.Module._load (module.js:312:12)

          at Module.require (module.js:362:17)

       

       

      Any idea of what the problem (and the solution of course)?

       

      Arnold

        • 1. Re: Cannot find module 'utf8'...
          Intel_Jesus

          Hi Arnold007,

           

          Can you provide the code you are using or a sample of your code that also throws the same error message?

           

          Regards,

          Intel_Jesus

          • 2. Re: Cannot find module 'utf8'...
            Arnold007

            Hi Jesus!

             

            Thanks for the reply and sorry for this late answer.

             

            Actually, my problem is now resolved.

             

            Somehow, the UTF8 module was not in the correct node_modules directory. I just copied it it in every single node_modules directory, and it works now.

             

            But still, I find the directory structure kind of messy and shaky; I have at least 5 of them and they are not all the same...

             

            Can't we just have a single node_modules directory where everything is?

             

            Now, I have a new problem :

             

            root@clanton:~/tinyWebServer# node server_socket.js

             

             

            /home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:23

              var xhr = new XMLHttpRequest({ agent: this.agent, xdomain: false });

                        ^

            TypeError: object is not a function

                at /home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:23:13

                at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:25:3)

                at Module._compile (module.js:449:26)

                at Object.Module._extensions..js (module.js:467:10)

                at Module.load (module.js:356:32)

                at Function.Module._load (module.js:312:12)

                at Module.require (module.js:362:17)

                at require (module.js:378:17)

                at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-xhr.js:6:15)

                at Module._compile (module.js:449:26)

                at Module.require (module.js:362:17)

                at require (module.js:378:17)

                at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-xhr.js:6:15)

                at Module._compile (module.js:449:26)

             

            It seems that the xhr variable being used somewhere else as global is affected by this xhr variable defined as local.

             

            That's probably because polling.js was called from a wrong node_modules (I have so many of them,I can understand).

             

            Can you help me on that last problem?

             

            Arnold

            • 3. Re: Cannot find module 'utf8'...
              Intel_Jesus

              Hi Arnold007,

               

              If you include additional libraries make sure they are in the same directory or give the full path of the library in the include header.

               

              Regards,

              Intel_Jesus

              • 4. Re: Cannot find module 'utf8'...
                Arnold007

                Hi!

                 

                I tried 3 js scripts (all using polling.js) and got the same error for all 3 (server_data.js, server_socket.js and server_chart.js) :

                 

                 

                login as: root

                root@clanton:~/tinyWebServer# ls

                Chart_min.js          basicserver.js        data.ejs              jquery_1_11_1_min.js  server.js             server_chart.js       server_express.js     views

                1. action.ejs            chart.ejs             index.ejs             node_modules          server_basic.js       server_data.js        server_socket.js

                root@clanton:~/tinyWebServer# node server_chart.js

                 

                /home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:23

                  var xhr = new XMLHttpRequest({ agent: this.agent, xdomain: false });

                            ^

                TypeError: object is not a function

                    at /home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:23:13

                    at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:25:3)

                    at Module._compile (module.js:449:26)

                    at Object.Module._extensions..js (module.js:467:10)

                    at Module.load (module.js:356:32)

                    at Function.Module._load (module.js:312:12)

                    at Module.require (module.js:362:17)

                    at require (module.js:378:17)

                    at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-xhr.js:6:15)

                    at Module._compile (module.js:449:26)

                root@clanton:~/tinyWebServer# node server_data.js

                 

                /home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:23

                  var xhr = new XMLHttpRequest({ agent: this.agent, xdomain: false });

                            ^

                TypeError: object is not a function

                    at /home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:23:13

                    at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:25:3)

                    at Module._compile (module.js:449:26)

                    at Object.Module._extensions..js (module.js:467:10)

                    at Module.load (module.js:356:32)

                    at Function.Module._load (module.js:312:12)

                    at Module.require (module.js:362:17)

                    at require (module.js:378:17)

                    at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-xhr.js:6:15)

                    at Module._compile (module.js:449:26)

                root@clanton:~/tinyWebServer# node server_socket.js

                 

                /home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:23

                  var xhr = new XMLHttpRequest({ agent: this.agent, xdomain: false });

                            ^

                TypeError: object is not a function

                    at /home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:23:13

                    at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling.js:25:3)

                    at Module._compile (module.js:449:26)

                    at Object.Module._extensions..js (module.js:467:10)

                    at Module.load (module.js:356:32)

                    at Function.Module._load (module.js:312:12)

                    at Module.require (module.js:362:17)

                    at require (module.js:378:17)

                    at Object.<anonymous> (/home/root/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/polling-xhr.js:6:15)

                    at Module._compile (module.js:449:26)

                root@clanton:~/tinyWebServer#

                 

                All the modules were installed wirth NPM as per the instructions in : http://senzations.net/wp-content/uploads/2014/66/Senzations14-Networking-nodejs.pdf .

                 

                And scripts are untouched.

                 

                Arnold

                • 5. Re: Cannot find module 'utf8'...
                  Intel_Alvarado

                  Hi Arnold007,

                  Do you still have any questions with this post? Please let us know if you still have questions, otherwise please mark assumed or correct answer.

                  Regards

                  Sergio