title: Uncaught TypeError: Cannot call method 'connectNative' in Native Messaging App
body: <p>I am working on native messaging app.I have created following files </p>
  
  <p>1.C++ conole app
  2.JS file
  3. manifet file
  I have created registry entry like this <img src="https://i.stack.imgur.com/8sIQ3.png" alt="enter image description here"></p>
  
  <p>Now I am getting error in the line <strong>port = chrome.runtime.connectNative(hostName);</strong>.I noticed chrome.runtime itself is undefined.let me know am I missing anything here.</p>
  
  <p><strong>Manifest.jason</strong></p>
  
  <pre><code>function connect() {
    //var m1 = chrome.runtime.getManifest();
    var hostName = "NM1";
    var t1 = chrome;
    appendMessage("Connecting to native messaging host &lt;b&gt;" + hostName + "&lt;/b&gt;")    
  
    port = chrome.runtime.connectNative(hostName);
    port.onMessage.addListener(onNativeMessage);
    port.onDisconnect.addListener(onDisconnected);
    updateUiState();
  }
  </code></pre>
  
  <p><strong>main.js</strong></p>
  
  <pre><code>function connect() {
    //var m1 = chrome.runtime.getManifest();
    var hostName = "NM1";  
    appendMessage("Connecting to native messaging host &lt;b&gt;" + hostName + "&lt;/b&gt;")
  
    port = chrome.runtime.connectNative(hostName);
    port.onMessage.addListener(onNativeMessage);
    port.onDisconnect.addListener(onDisconnected);
    updateUiState();
  }
  </code></pre>