Is there a way to Handle SerialPort Connections through JavaScript?

I’ve seen Many Solutions But all of them Use C#, and I want to use JavaScript.
I tried:

import System.IO.Ports;
public static var sp : SerialPort ;
sp.BaudRate = 9600;
sp.PortName ="COM4";
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.StopBits = StopBits.One;

but I keep getting this error:
-NullReferenceException: Object reference not set to an instance of an object
Unityinojava.OpenConection () (at Assets/Unityinojava.js:41)
Unityinojava.Start () (at Assets/Unityinojava.js:10)

Full code Bellow:

#pragma strict
import System.IO.Ports;
public static var sp : SerialPort ;
sp.BaudRate = 9600;
sp.PortName ="COM4";
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.StopBits = StopBits.One;
var count:int = 0;
var message: String;
var message1: String;
var message2 : int;

function Start () {
OpenConection();
}
function OnGUI()
{
	GUI.Label(new Rect(230,60,500,20),""+ message1+"Recebido"+ message2);
	GUI.Label(new Rect(120,10,500,30),"Status:"+message);
	if (GUI.Button(new Rect(10,60,200,30), "Liga LED"))
	{
		if (sp.IsOpen)
		{
			message1 = "Sent1";
			sp.Write("1");
			message2 = sp.ReadByte();
		}
	}
	if (GUI.Button(Rect(10,150,200,30),"Desliga LED"))
	{
		if (sp.IsOpen)
		{
			message1= "Sent2";
			sp.Write("2");
			message2= sp.ReadByte();
		}
	}
}

function Update () 
{
}
function OpenConection()
{
	
	if(sp!=null)
	{
		if (sp.IsOpen)
		{
			sp.Close();
			message="Fechando porta por que ja estava aberta";
		}else
		{
			sp.Open();//Abrindo conexao
			sp.ReadTimeout = 100;//Timeout Antes de reportar erro
			message = "Porta Aberta";
		}
		
	}else
	{
		if(sp.IsOpen)
		{
			print("Porta ja esta aberta");
		}else
		{
		 print("Porta esta Nula");
		}
	}
}
function OnApplicationQuit()
{
	sp.Close();
}

There is no place in your code where you initialize your sp variable. And that’s why you get NullReferenceException on second sp.IsOpen line. You have to initialize sp variable:

sp = new SerialPort();

and copy this block:

sp.BaudRate = 9600;
sp.PortName ="COM4";
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.StopBits = StopBits.One;

after initialization.