Search code examples
node.jsnpmts-nodeskaffold

How to FIX: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: when using ts-node-dev in start script


I am writing a node.js app using express, docker, and Kubernetes. node -v is v12.16.3 Docker version 19.03.1, build 74b1e89e8a Kubernetes using minikube

I created one Service named as auth and when I tried to deploy it using skaffold dev command I am getting below error

[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! [email protected] 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 [email protected] 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

Bwlow is package.json file

{
  "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 file

FROM node:lts-alpine

WORKDIR /app
COPY package.json .
RUN npm install
COPY . .

CMD ["npm", "start"]

Below is the 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: .

Solution

  • Solution: Modify the package.json with value as "start": "ts-node-dev src/index.ts --poll" And use node:lte-alpine in the Dockerfile