Grunt watch 在 Kubernetes 中抛出 sync:dev not found 错误 Sails.js
Grunt watch throws a sync:dev not found error with Sails.js in Kubernetes
我使用 Minikube 来模拟我的 Kubernetes 生产架构。
在集群中,我需要创建一个网站,我决定使用 Sails.js.
这是我的 Kubernetes 配置:
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
这里是柔和的白色标签:v1 Docker 图片:
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"]
当我启动我的集群并构建我的 pod 时,一切都很顺利。
我的 Sails.js 日志一尘不染,我可以在浏览器中看到主页:完全没有问题。我在开箱即用的 Web 应用程序模式下使用 Sails.js v1.1.0。我也可以看到 Grunt 已启动并正在观看。
现在如果我编辑一个 .less 文件,我会得到一个不友好的消息:
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.
我确定我的 .less 文件没有错误(十六进制代码版本),我的 .tmp 文件夹是可写的(例如 touch .tmp/foo 正在工作)并且我相信 Grunt 已正确安装开箱即用...
那我真不知道这是怎么回事...
你们有什么想法吗?
提前谢谢
我认为您 运行 正好 this。看起来它特定于节点版本。您可以为您的节点尝试早期版本 docker image:
FROM node:8.12.0-stretch
正如您在 docker 文件中所述
FROM node:10.13.0-stretch
如果您仍想使用节点10.x+并避免此错误,您可以使用这里讨论的方法。漂亮又简单:)
https://github.com/balderdashy/sails/issues/4513#issuecomment-468389534
我使用 Minikube 来模拟我的 Kubernetes 生产架构。 在集群中,我需要创建一个网站,我决定使用 Sails.js.
这是我的 Kubernetes 配置:
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
这里是柔和的白色标签:v1 Docker 图片:
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"]
当我启动我的集群并构建我的 pod 时,一切都很顺利。 我的 Sails.js 日志一尘不染,我可以在浏览器中看到主页:完全没有问题。我在开箱即用的 Web 应用程序模式下使用 Sails.js v1.1.0。我也可以看到 Grunt 已启动并正在观看。
现在如果我编辑一个 .less 文件,我会得到一个不友好的消息:
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.
我确定我的 .less 文件没有错误(十六进制代码版本),我的 .tmp 文件夹是可写的(例如 touch .tmp/foo 正在工作)并且我相信 Grunt 已正确安装开箱即用...
那我真不知道这是怎么回事...
你们有什么想法吗?
提前谢谢
我认为您 运行 正好 this。看起来它特定于节点版本。您可以为您的节点尝试早期版本 docker image:
FROM node:8.12.0-stretch
正如您在 docker 文件中所述
FROM node:10.13.0-stretch
如果您仍想使用节点10.x+并避免此错误,您可以使用这里讨论的方法。漂亮又简单:)
https://github.com/balderdashy/sails/issues/4513#issuecomment-468389534