title: Getting TypeError: "path" is not defined: undefined while executing serial port program for windows using JavaScript
body: <p>I am trying to execute a Serial Port program for windows based application using JavaScript and Arduino Uno. This is the link i referred <a href="https://channel9.msdn.com/Blogs/raw-tech/Arduino-talks-back-to-Nodejs-Drama-on-the-Serial-Port" rel="nofollow noreferrer">https://channel9.msdn.com/Blogs/raw-tech/Arduino-talks-back-to-Nodejs-Drama-on-the-Serial-Port</a>. While i try to execute the program by issuing npm start COMxx. Iam getting the following error.</p>
  <pre><code>App threw an error during load
  TypeError: &quot;path&quot; is not defined: undefined
      at new SerialPort (C:\serial test js\serial-app\node_modules\@serialport\stream\lib\index.js:116:11)
      at Object.&lt;anonymous&gt; (C:\serial test js\serial-app\src\index.js:7:16)
      at Module._compile (internal/modules/cjs/loader.js:1078:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
      at Module.load (internal/modules/cjs/loader.js:935:32)
      at Module._load (internal/modules/cjs/loader.js:776:14)
      at Function.f._load (electron/js2c/asar_bundle.js:5:12684)
      at loadApplicationPackage (C:\serial test js\serial-app\node_modules\electron\dist\resources\default_app.asar\main.js:110:16)
      at Object.&lt;anonymous&gt; (C:\serial test js\serial-app\node_modules\electron\dist\resources\default_app.asar\main.js:222:9)
      at Module._compile (internal/modules/cjs/loader.js:1078:30)
  </code></pre>
  <p>And this is my code</p>
  <pre><code>const { app, BrowserWindow } = require('electron');
  const path = require('path');
  const SerialPort = require('serialport');
  const Readline = SerialPort.parsers.Readline;
  const portname = process.argv[2];
  
  const myPort = new SerialPort(portname, {
    baudRate:9600,
    parser: new Readline(&quot;\n&quot;)
  });
  
  myPort.on('open',onOpen);
  myPort.on('data',onData);
  
  // Handle creating/removing shortcuts on Windows when installing/uninstalling.
  if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
    app.quit();
  }
  
  const createWindow = () =&gt; {
    // Create the browser window.
    const mainWindow = new BrowserWindow({
      width: 800,
      height: 600,
    });
  
    // and load the index.html of the app.
    mainWindow.loadFile(path.join(__dirname, 'index.html'));
  
    // Open the DevTools.
    mainWindow.webContents.openDevTools();
  };
  
  function onOpen(){
    console.log(&quot;Open Connection&quot;);
  }
  
  function onData(data){
    console.log(&quot;on Data &quot;+data);
  
  
  }
  // This method will be called when Electron has finished
  // initialization and is ready to create browser windows.
  // Some APIs can only be used after this event occurs.
  app.on('ready', createWindow);
  
  // Quit when all windows are closed, except on macOS. There, it's common
  // for applications and their menu bar to stay active until the user quits
  // explicitly with Cmd + Q.
  app.on('window-all-closed', () =&gt; {
    if (process.platform !== 'darwin') {
      app.quit();
    }
  });
  
  app.on('activate', () =&gt; {
    // On OS X it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (BrowserWindow.getAllWindows().length === 0) {
      createWindow();
    }
  });
  
  // In this file you can include the rest of your app's specific main process
  // code. You can also put them in separate files and import them here.
  </code></pre>
  <p>Help me to resolve the issue</p>