5 Replies Latest reply on May 25, 2016 6:21 AM by Jek2k

    "Illegal instruction" when using nodejs with mysqlite

    quocbao

      Hello everyone,

       

      I'm learning how to use mysqlite3 library in nodejs.

       

      In my compute, I'm using Ubuntu. it is ok when I'm using mysqlite3 library (with nodejs 0.10.25):

      var sqlite3 = require('sqlite3').verbose();
      var db = new sqlite3.Database('mydb.db'); 
      var check; 
      db.serialize(function() { 
       
        db.run("CREATE TABLE if not exists user_info (info TEXT)"); 
        var stmt = db.prepare("INSERT INTO user_info VALUES (?)"); 
        for (var i = 0; i < 10; i++) { 
            stmt.run("Ipsum " + i); 
        } 
        stmt.finalize(); 
       
        db.each("SELECT rowid AS id, info FROM user_info", function(err, row) { 
            console.log(row.id + ": " + row.info); 
        }); 
      }); 
       
      db.close();
      
      
      

       

      I got this result: (everything was ok)

      snapshot18.png

       

      But when I tried to use the same code in my Galileo Gen 2 board (iot-devkit 1.5), i got the "Illegal Instruction" error (with nodejs 0.10.38):

      snapshot19.png


      I installed mysqlite3 on Galileo by npm:

      npm install sqlite3
      
      
      

       

      As I heard that Raspberry Pi also has this problem and there is a version of nodejs for ARM CPU (here).

       

      Can anyone give me a suggestion to run mysqlite3 in nodejs on Galileo board ? Thanks

        • 1. Re: "Illegal instruction" when using nodejs with mysqlite
          xbolshe

          Hi ,

           

          it seems you are trying to follow Node and SQLite tutorial | Code for geek

          And it seems the error "Illegal Instruction" means that sqlite3 you have installed is not intended for Galileo board,

          because Galileo's CPU does not support some commands supported by your PC.

           

          Need to install sqlite3 intended for Galileo board.

           

          BR,

          xbolshe

          • 2. Re: "Illegal instruction" when using nodejs with mysqlite
            quocbao

            Hello xbolshe,

             

            First, thank you for giving your help.

             

            I have just found that sqlite3 can run perfectly on my galileo

            snapshot23.png

            I forgot testing sqlite3 by using commandline: Commandline Shell for SQLite . This mistake made me belive that sqlite3 isn't compatibe with Galileo board (iot-devkit).

             

            So that I think the problem is NodeJS can't use sqlite3 library

            • 3. Re: "Illegal instruction" when using nodejs with mysqlite
              xbolshe

              Hi,

               

              probably the problem may be related with sqlite3.node - a nodejs module between sqlite3 library and nodejs.

               

              BR,

              xbolshe

              • 4. Re: "Illegal instruction" when using nodejs with mysqlite
                Jek2k

                Hello!

                 

                How use sqlite3.node on Intel Galileo Gen 2, standart Yocto?

                 

                1.I make dir ~/a,

                2. create file package.json :

                {
                   "name": "node-sqlite",
                   "version": "1.0.1",
                   "dependencies": {
                     "sqlite3": "~2.2.3"
                   }
                }

                 

                3. in folder ~/a run "npm install" and have errors:

                 

                npm ERR! sqlite3@2.2.7 install: `node-pre-gyp install --fallback-to-build`     

                npm ERR! Exit status 1                                                         

                npm ERR!                                                                       

                npm ERR! Failed at the sqlite3@2.2.7 install script.                           

                npm ERR! This is most likely a problem with the sqlite3 package,               

                npm ERR! not with npm itself.                                                  

                npm ERR! Tell the author that this fails on your system:                       

                npm ERR!     node-pre-gyp install --fallback-to-build                          

                npm ERR! You can get their info via:                                           

                npm ERR!     npm owner ls sqlite3                                              

                npm ERR! There is likely additional logging output above.                      

                npm ERR! System Linux 3.8.7-yocto-standard                                     

                npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"                      

                npm ERR! cwd /home/root/a                                                      

                npm ERR! node -v v0.10.38                                                      

                npm ERR! npm -v 1.4.28                                                         

                npm ERR! code ELIFECYCLE                                                       

                npm ERR! not ok code 0

                 

                SQLite3 on command line work without problem.

                Is Node.JS work with SQLite3 on Intel Galileo Gen 2?

                Anybody have working sample?

                • 5. Re: "Illegal instruction" when using nodejs with mysqlite
                  Jek2k

                  Before install sqlite3.node need to install development tools: "opkg install packagegroup-core-buildessential"