title: NodeJS with Scaffold: How to set up dev environment?
body: <p>I'm trying to set up a dev environment for my Nodejs project using Skaffold to handle k8s. I notice that sometime when there's an error (usually syntax error cause I'm using auto-save), the entire local server seem to stop working and the error message doesn't get displayed. Sometimes it can fix itself but most of the time I have to restart skaffold. I have no idea what's causing the issues since the error message can be different everytime: &quot;unable to connect to pod ...&quot; , &quot;502 error&quot;, &quot;skipping deploy due to sync error&quot; ...</p>
  <p>Here's my simple dockerfile for node:</p>
  <pre><code>FROM node:alpine
  
  WORKDIR /app
  
  COPY package.json .
  RUN npm install
  COPY . .
  
  CMD [&quot;npm&quot;, &quot;start&quot;]
  </code></pre>
  <p>Package.json</p>
  <pre><code>{
    &quot;name&quot;: &quot;auth&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;Authorization Service for Ticketting&quot;,
    &quot;main&quot;: &quot;index.js&quot;,
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;ts-node-dev src/index.ts&quot;
    },
    &quot;author&quot;: &quot;Nam Nguyen&quot;,
    &quot;license&quot;: &quot;ISC&quot;,
    &quot;devDependencies&quot;: {
      &quot;ts-node-dev&quot;: &quot;^1.0.0&quot;,
      &quot;typescript&quot;: &quot;^4.0.5&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@types/express&quot;: &quot;^4.17.8&quot;,
      &quot;express&quot;: &quot;^4.17.1&quot;,
      &quot;express-validator&quot;: &quot;^6.6.1&quot;
    }
  }
  </code></pre>
  <p>Deployment yaml</p>
  <pre><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: auth-depl
  spec:
    replicas: 3
    selector:
      matchLabels:
        app: auth
    template:
      metadata:
        labels:
          app: auth
      spec:
        containers:
          - name: auth
            image: namng191/auth
  ---
  apiVersion: v1
  kind: Service
  metadata:
    name: auth-srv
  spec:
    type: ClusterIP
    selector:
      app: auth
    ports:
      - name: auth
        protocol: TCP
        port: 3000
        targetPort: 3000
  </code></pre>
  <p>Ingress config yaml</p>
  <pre><code>apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: ingress-service
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/use-regex: 'true'
  spec:
    rules:
      - host: ticketting.dev
        http:
          paths:
            - path: /api/users/?(.*)
              pathType: Prefix
              backend:
                service:
                  name: auth-srv
                  port:
                    number: 3000
  </code></pre>
  <p>Skaffold yaml</p>
  <pre><code>apiVersion: skaffold/v2beta9
  kind: Config
  deploy:
    kubectl:
      manifests:
        - ./infra/k8s/*
  build:
    local:
      push: false
    artifacts:
      - image: namng191/auth
        context: ./auth
        docker:
          dockerfile: Dockerfile
        sync:
          manual:
            - src: 'src/**/*.ts'
              dest: .
  </code></pre>