Grunt watch throws a sync:dev not found error with Sails.js in Kubernetes

11/13/2018

I use Minikube for simulating my Kubernetes production architecture. In the cluster, I need to create a website and I decided to use Sails.js.

Here is my Kubernetes configuration :

apiVersion: v1
kind: PersistentVolume
metadata:
  name: white-label-storage-persistent-volume
  labels:
    type: local
    app: white-label
    role: master
    tier: backend
spec:
  storageClassName: manual
  capacity:
    storage: 5Gi
  accessModes:
  - ReadWriteMany
  hostPath:
    path: "/white-label-data"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: white-label-storage-persistent-volume-claim
  labels:
    app: white-label
    role: master
    tier: backend
spec:
  storageClassName: manual
  accessModes:
  - ReadWriteMany
  resources:
    requests:
      storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: white-label-deployment
  labels:
    app: white-label
    role: master
    tier: backend
spec:
  replicas: 1
  strategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: white-label
      role: master
      tier: backend
  template:
    metadata:
      labels:
        app: white-label
        role: master
        tier: backend
    spec:
      containers:
      - name: white-label
        image: pastel-white-label:v1
        imagePullPolicy: IfNotPresent
        workingDir: "/usr/src/app"
        resources:
          requests:
            memory: 2Gi
            cpu: 1
          limits:
            memory: 4Gi
            cpu: 2
        ports:
        - containerPort: 1337
          protocol: TCP
        volumeMounts:
        - mountPath: "/data"
          name: white-label-persistent-volume
      volumes:
        - name: white-label-persistent-volume
          persistentVolumeClaim:
            claimName: white-label-storage-persistent-volume-claim
---
apiVersion: v1
kind: Service
metadata:
  name: white-label-service
  labels:
    app: white-label
    role: master
    tier: backend
spec:
  type: LoadBalancer
  ports:
  - port: 1337
    protocol: TCP
    nodePort: 30003
  selector:
    app: white-label
    role: master
    tier: backend
  sessionAffinity: None
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
  name: white-label-hpa
  labels:
    app: white-label
    role: master
    tier: backend
  namespace: default
spec:
  maxReplicas: 5
  minReplicas: 1
  scaleTargetRef:
    apiVersion: extensions/v1
    kind: Deployment
    name: white-label-deployment
  targetCPUUtilizationPercentage: 80

And here is the pastel-white-label:v1 Docker image :

FROM node:10.13.0-stretch

WORKDIR /usr/src/app
COPY . ./

RUN npm install -g sails npm-check-updates
RUN npm install @sailshq/connect-redis --save
RUN npm install

CMD ["sails", "lift"]

When I start my cluster and build my pod, everything works like a charm. My Sails.js log is spotless, I can see the home page in the browser: no problem at all. I use Sails.js v1.1.0 in Web app mode out of the box BTW. I can see as well that Grunt is launched and is watching.

Now if I edit a .less file though, I get an unfriendly:

debug: -------------------------------------------------------
error: ** Grunt :: An error occurred. **
error: 
------------------------------------------------------------------------

Aborted due to warnings.
Running "watch" task
Waiting...
>> File "assets/styles/styleguide/colors.less" changed.
Loading "sync.js" tasks...ERROR
>> TypeError: Cannot read property 'length' of undefined
Warning: Task "sync:dev" not found.

I am sure my .less file has no error (hexa code edition), my .tmp folder is writable (touch .tmp/foo is working for instance) and I believe Grunt is correctly installed as it comes out of the box...

Then I really don't know what is going on here...

Do you guys have an idea, please ?

Thank you ahead

-- Zaziffic
gruntjs
kubernetes
minikube
sails.js

2 Answers

4/23/2019

As you stated in your docker file

FROM node:10.13.0-stretch

if you still want to use node 10.x+ and avoid this error, you may use the method discussed here. Nice and simple :)

https://github.com/balderdashy/sails/issues/4513#issuecomment-468389534

-- Taha
Source: StackOverflow

11/14/2018

I think you are running into exactly this. Looks like it's specific to the node version. You can try an earlier version for your node docker image:

FROM node:8.12.0-stretch
-- Rico
Source: StackOverflow