<p>I am working on a NextJS project to create a Kubernetes Job. To create a Job on minikube, I am using config.yaml that is generally generated whenever we start the minikube. So I am using the same file to make connection with Kubernetes API.
Now to make connection with kubernetes(minikube), I am using following code:</p>
<pre><code>import k8s from &quot;@kubernetes/client-node&quot;;

let kubeAPI = null;

const createKubeAPI = async () =&gt; {
  const kc = new k8s.KubeConfig();
  const path = &quot;../config/k8sConfig.yaml&quot;;
  console.log(path);
  kc.loadFromFile(path);

  const k8sApi = kc.makeApiClient(k8s.BatchV1Api);

  return k8sApi;
};

export const get = () =&gt; kubeAPI;

export const create = async () =&gt; {
  kubeAPI = await createKubeAPI();
};
</code></pre>
<p>And in another .js file, by using the function created in the above code creating a new job or displaying the running the jobs.</p>
<p>But when running above code, it is showing the error. Complete error looks like:</p>
<pre><code>event - compiled client and server successfully in 7.4s (224 modules)
null
error - utils\kube-utils\kubeClient.js (6:17) @ createKubeAPI
TypeError: Cannot read properties of undefined (reading 'KubeConfig')
  4 | 
  5 | const createKubeAPI = async () =&gt; {
&gt; 6 |   const kc = new k8s.KubeConfig();
    |                 ^
  7 |   // kc.loadFromDefault();
  8 |   const path = &quot;../config/k8sConfig.yaml&quot;;
  9 |   console.log(path);
</code></pre>
<p>Can someone help me or guide me, what am I doing wrong here?</p>

<p>It seems there is no default export, so when using ES6 module imports, you need to either use named imports:</p>
<pre><code>import { KubeConfig, CoreV1Api } from '@kubernetes/client-node';
</code></pre>
<p>or import everything:</p>
<pre><code>import * as k8s from '@kubernetes/client-node';

new k8s.KubeConfig();
</code></pre>
