node.js - 如何修复用于运行Node.js的: The feature watch recursively is unavailable on the current platform,

标签 node.js typescript docker dockerfile alpine

我正在尝试在Docker容器中运行Typescript express.js。运行docker之后,我得到以下错误:

> ts-node-dev src/app.ts

Using ts-node version 8.10.1, typescript version 3.9.2
TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    at Object.watch (fs.js:1441:11)
    at add (/app/node_modules/filewatcher/index.js:74:34)
    at /app/node_modules/filewatcher/index.js:93:5
    at FSReqCallback.oncomplete (fs.js:176:5)

我的Dockerfile:
FROM node:alpine

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

CMD ["npm","start"]

和package.json文件:
{
  "name": "app-name",
  "version": "1.0.0",
  "description": "Init master",
  "main": "src/app.ts",
  "scripts": {
    "build": "./node_modules/.bin/tsc",
    "start": "ts-node-dev src/app.ts"
  },
  "repository": {
    "type": "git",
    "url": "https://*****@dev.azure.com/********"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "celebrate": "^12.1.1",
    "colors": "^1.4.0",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "event-dispatch": "^0.4.1",
    "eventemitter3": "^4.0.0",
    "express": "^4.17.1",
    "helmet": "^3.22.0",
    "jsonwebtoken": "^8.5.1",
    "moment": "^2.25.3",
    "mongoose": "^5.9.13",
    "morgan": "^1.10.0",
    "ms": "^2.1.2",
    "pbkdf2": "^3.0.17",
    "redis": "^3.0.2",
    "reflect-metadata": "^0.1.13",
    "status-code-enum": "^1.0.0",
    "swagger-jsdoc": "^4.0.0",
    "swagger-ui-express": "^4.1.4",
    "ts-node": "^8.10.1",
    "typedi": "^0.8.0",
    "uuid": "^8.0.0",
    "winston": "^3.2.1"
  },
  "devDependencies": {
    "@types/express": "^4.17.6",
    "@types/mongoose": "^5.7.16",
    "@types/node": "^13.13.5",
    "ts-node-dev": "^1.0.0-pre.44",
    "typescript": "^3.8.3"
  }
}

P.S.我已决定包括此修复程序:
更改Dockerfile:
FROM node:lts-alpine

并更改package.json:
"start": "ts-node-dev src/app.ts --poll"

最佳答案

节点v14对fs.watch() API进行了重大更改,特别是recursive选项(Linux从未支持过)now raises the ERR_FEATURE_UNAVAILABLE_ON_PLATFORM error if used on Linux

一个错误报告和修复已提交给filewatcher:https://github.com/fgnass/filewatcher/pull/6

在合并该修补程序并发布新版本之前,您需要坚持使用NodeJS filewatcher软件包以包含该补丁。

关于node.js - 如何修复用于运行Node.js的: The feature watch recursively is unavailable on the current platform,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61806341/

相关文章:

docker - docker run hello-world中的错误(守护程序的错误响应:OCI运行时创建失败:)

node.js - EADDRNOTAVAIL 在许多 http.get 请求到 localhost 之后

node.js - FFMPEG : Conversion Failed Error when trying trying to create facebook stream from image and audio?

reactjs - React、样式组件和 TypeScript : How to wrap a styled component in a functional component

javascript - 类验证器:验证数值的位数

python - 查看来自 PID != 1 的日志

docker - 如何使用 SELinux 在 Kubernetes 中挂载 HostPath 卷

javascript - 在 react-router v4 中使用 React IndexRoute

javascript - Node js 检查 mysql 表中是否存在数据。- TypeError : res. send 不是函数

javascript - 找不到名称 'require' 。 Angular 2