我正在使用express,docker和Kubernetes编写一个node.js应用程序。 节点-v为v12.16.3 Docker版本19.03.1,内部版本74b1e89e8a 使用minikube的Kubernetes
我创建了一个名为auth的服务,当我尝试使用skaffold dev命令部署它时,我遇到了错误
[91m[auth-depl-56db74bf85-b2kst auth] ←[0m
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mUsing ts-node version 8.10.2, typescript version 3.9.5
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mTypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0m at Object.watch (fs.js:1441:11)
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0m at add (/app/node_modules/filewatcher/index.js:74:34)
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0m at /app/node_modules/filewatcher/index.js:93:5
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0m at FSReqCallback.oncomplete (fs.js:176:5)
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR! code ELIFECYCLE
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR! errno 1
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR! auth@1.0.0 start: `ts-node-dev src/index.ts --poll`
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR! Exit status 1
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR!
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR! Failed at the auth@1.0.0 start script.
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR! This is probably not a problem with npm. There is likely additional logging output above.
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0m
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR! A complete log of this run can be found in:
←[91m[auth-depl-56db74bf85-b2kst auth] ←[0mnpm ERR! /root/.npm/_logs/2020-06-05T09_25_50_079Z-debug.log
Blow是package.json文件
{
"name": "auth",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "ts-node-dev src/index.ts --poll"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/express": "^4.17.6",
"express": "^4.17.1",
"nodemon": "^2.0.4",
"typescript": "^3.9.5"
},
"devDependencies": {
"ts-node-dev": "^1.0.0-pre.44"
}
}
Docker文件
FROM node:lts-alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
CMD ["npm", "start"]
下面是skaffold.yaml
apiVersion: skaffold/v2alpha3
kind: config
deploy:
kubectl:
manifests:
- ./infra/k8s/*
build:
local:
push: false
artifacts:
- image: xxxxxx/auth
context: auth
docker:
dockerfile: Dockerfile
sync:
manual:
- src: 'src/**/*.ts'
dest: .
答案 0 :(得分:0)
解决方案: 修改package.json的值为 “开始”:“ ts-node-dev src / index.ts --poll” 并在Dockerfile中使用node:lte-alpine