schussvogeltot: wie kann ich mit cordova node.js starten?

Ich möchte einen server mit einer app auf meinem Androidhandy starten. (ohneconsole)

PS: Ich habe nur von JXcore gelesen, aber ich fidne keine gute Anleitung dafür die ich verstehe. Ein Bsp. würde mir vielleicht helfen.

PS: Hier mal ein Link dazu http://jxcore.com/turn-node-applications-into-executables/

  1. Zur Zeit bekomme ich den Fehler:

    Ausnahmefehler in Zeile 23, Spalte 9 in ms-appx://io.cordova.myapp38d07c/www/scripts/index.js

    0x800a1391 - Laufzeitfehler in JavaScript: "require" ist undefiniert

    1. Ich habe jetzt angefangen ironic zu verwenden. Dort kann man über hooks shebang zeilen einfügen und starten lassen.

      z.B. ist dieser Hook schon standartmäßig dabei:

      
      #!/usr/bin/env node
      
      // Add Platform Class
      // v1.0
      // Automatically adds the platform class to the body tag
      // after the `prepare` command. By placing the platform CSS classes
      // directly in the HTML built for the platform, it speeds up
      // rendering the correct layout/style for the specific platform
      // instead of waiting for the JS to figure out the correct classes.
      
      var fs = require('fs');
      var path = require('path');
      
      var rootdir = process.argv[2];
      
      function addPlatformBodyTag(indexPath, platform) {
        // add the platform class to the body tag
        try {
          var platformClass = 'platform-' + platform;
          var cordovaClass = 'platform-cordova platform-webview';
      
          var html = fs.readFileSync(indexPath, 'utf8');
      
          var bodyTag = findBodyTag(html);
          if(!bodyTag) return; // no opening body tag, something's wrong
      
          if(bodyTag.indexOf(platformClass) > -1) return; // already added
      
          var newBodyTag = bodyTag;
      
          var classAttr = findClassAttr(bodyTag);
          if(classAttr) {
            // body tag has existing class attribute, add the classname
            var endingQuote = classAttr.substring(classAttr.length-1);
            var newClassAttr = classAttr.substring(0, classAttr.length-1);
            newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote;
            newBodyTag = bodyTag.replace(classAttr, newClassAttr);
      
          } else {
            // add class attribute to the body tag
            newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">');
          }
      
          html = html.replace(bodyTag, newBodyTag);
      
          fs.writeFileSync(indexPath, html, 'utf8');
      
          process.stdout.write('add to body class: ' + platformClass + '\n');
        } catch(e) {
          process.stdout.write(e);
        }
      }
      
      function findBodyTag(html) {
        // get the body tag
        try{
          return html.match(/<body(?=[\s>])(.*?)>/gi)[0];
        }catch(e){}
      }
      
      function findClassAttr(bodyTag) {
        // get the body tag's class attribute
        try{
          return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0];
        }catch(e){}
      }
      
      if (rootdir) {
      
        // go through each of the platform directories that have been prepared
        var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
      
        for(var x=0; x<platforms.length; x++) {
          // open up the index.html file at the www root
          try {
            var platform = platforms[x].trim().toLowerCase();
            var indexPath;
      
            if(platform == 'android') {
              indexPath = path.join('platforms', platform, 'assets', 'www', 'index.html');
            } else {
              indexPath = path.join('platforms', platform, 'www', 'index.html');
            }
      
            if(fs.existsSync(indexPath)) {
              addPlatformBodyTag(indexPath, platform);
            }
      
          } catch(e) {
            process.stdout.write(e);
          }
        }
      
      }
      

      Bei Windows kann ich auch debugen mit visual Studio. per usb auf meinem android hand bekomme ich dann fehlermeldung wegen der shebangzeile. Eigentlich sollte nun diese ausgeführt werden und node starten.

      hier mal die Fehlermeldungen:

      Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand Warnung Ungültiges Zeichen ionic-js-blank2 C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\hooks\after_prepare\010_add_platform_class.js 1 Warnung Syntaxfehler im regulären Ausdruck ionic-js-blank2 C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\hooks\after_prepare\010_add_platform_class.js 1 Warnung ';' erwartet ionic-js-blank2 C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\hooks\after_prepare\010_add_platform_class.js 1 Warnung ';' erwartet ionic-js-blank2 C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\hooks\after_prepare\010_add_platform_class.js 1 Warnung Ungültiges Zeichen ionic-js-blank2 C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\hooks\before_run\start_node.js 1 Warnung Syntaxfehler im regulären Ausdruck ionic-js-blank2 C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\hooks\before_run\start_node.js 1 Warnung ';' erwartet ionic-js-blank2 C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\hooks\before_run\start_node.js 1 Warnung ';' erwartet ionic-js-blank2 C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\hooks\before_run\start_node.js 1 Fehler FAILURE: Build failed with an exception. ionic-js-blank2 1 Fehler * What went wrong: ionic-js-blank2 1 Fehler Could not connect to the Gradle daemon. ionic-js-blank2 1 Fehler Daemon uid: 91913a9d-f074-46db-bca8-496fea02aedc with diagnostics: ionic-js-blank2 1 Fehler Daemon pid: 4292 ionic-js-blank2 1 Fehler log file: C:\Users\se.gradle\daemon\2.2.1\daemon-4292.out.log ionic-js-blank2 1 Fehler ----- Last 20 lines from daemon log file - daemon-4292.out.log ----- ionic-js-blank2 1 Fehler 21:10:35.076 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false ionic-js-blank2 1 Fehler 21:10:35.076 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true ionic-js-blank2 1 Fehler 21:10:35.076 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface Hyper-V Virtual Ethernet Adapter-WFP 802.3 MAC Layer LightWeight Filter-0000 ionic-js-blank2 1 Fehler 21:10:35.076 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding IP addresses for network interface Hyper-V Virtual Ethernet Adapter #2-WFP 802.3 MAC Layer LightWeight Filter-0000 ionic-js-blank2 1 Fehler 21:10:35.076 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a loopback interface? false ionic-js-blank2 1 Fehler 21:10:35.076 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Is this a multicast interface? true ionic-js-blank2 1 Fehler 21:10:35.076 [DEBUG] [org.gradle.messaging.remote.internal.inet.InetAddressFactory] Adding loopback multicast interface Hyper-V Virtual Ethernet Adapter #2-WFP 802.3 MAC Layer LightWeight Filter-0000 ionic-js-blank2 1 Fehler 21:10:35.092 [DEBUG] [org.gradle.messaging.remote.internal.inet.TcpIncomingConnector] Listening on [8540236f-9a62-4dfd-ab10-74196cded3e6 port:57620, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. ionic-js-blank2 1 Fehler 21:10:35.092 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] Daemon starting at: Tue Jun 06 21:10:35 CEST 2017, with address: [8540236f-9a62-4dfd-ab10-74196cded3e6 port:57620, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] ionic-js-blank2 1 Fehler 21:10:35.092 [INFO] [org.gradle.launcher.daemon.server.DomainRegistryUpdater] Advertising the daemon address to the clients: [8540236f-9a62-4dfd-ab10-74196cded3e6 port:57620, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]] ionic-js-blank2 1 Fehler 21:10:35.092 [DEBUG] [org.gradle.launcher.daemon.server.DomainRegistryUpdater] Advertised daemon context: DefaultDaemonContext[uid=91913a9d-f074-46db-bca8-496fea02aedc,javaHome=C:\Program Files (x86)\Java\jdk1.8.0_131,daemonRegistryDir=C:\Users\se.gradle\daemon,pid=4292,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252,-Duser.country=DE,-Duser.language=de,-Duser.variant] ionic-js-blank2 1 Fehler 21:10:35.092 [DEBUG] [org.gradle.launcher.daemon.registry.PersistentDaemonRegistry] Storing daemon address: [8540236f-9a62-4dfd-ab10-74196cded3e6 port:57620, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]], context: DefaultDaemonContext[uid=91913a9d-f074-46db-bca8-496fea02aedc,javaHome=C:\Program Files (x86)\Java\jdk1.8.0_131,daemonRegistryDir=C:\Users\se.gradle\daemon,pid=4292,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252,-Duser.country=DE,-Duser.language=de,-Duser.variant] ionic-js-blank2 1 Fehler 21:10:35.107 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on daemon addresses registry. ionic-js-blank2 1 Fehler 21:10:35.107 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired. ionic-js-blank2 1 Fehler 21:10:35.186 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry. ionic-js-blank2 1 Fehler 21:10:35.186 [LIFECYCLE] [org.gradle.launcher.daemon.server.Daemon] Daemon server started. ionic-js-blank2 1 Fehler 21:10:35.201 [DEBUG] [org.gradle.launcher.daemon.bootstrap.DaemonStartupCommunication] Completed writing the daemon greeting. Closing streams... ionic-js-blank2 1 Fehler 21:10:35.201 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] requestStopOnIdleTimeout(10800000 MILLISECONDS) called on daemon ionic-js-blank2 1 Fehler 21:10:35.201 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] Idle timeout: waiting for daemon to stop or be idle for 10800000ms ionic-js-blank2 1 Fehler 21:10:35.201 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] Daemon is idle, sleeping until state change or idle timeout at Wed Jun 07 00:10:34 CEST 2017 ionic-js-blank2 1 Fehler ----- End of the daemon log ----- ionic-js-blank2 1 Fehler * Try: ionic-js-blank2 1 Fehler Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. ionic-js-blank2 1 Fehler Error code 1 for command: cmd with args: /s,/c,""C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\platforms\android\gradlew" cdvBuildRelease -b "C:\Users\se\Documents\Visual Studio 2015\Projects\ionic-js-blank2\ionic-js-blank2\platforms\android\build.gradle" -Dorg.gradle.daemon=true -Pandroid.useDeprecatedNdk=true" ionic-js-blank2 1