如何解决:当前平台上递归监视功能不可用,正在用于运行 Node.js [英] How to fix: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js

查看:80
本文介绍了如何解决:当前平台上递归监视功能不可用,正在用于运行 Node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 docker 容器中运行 typescript express.js.运行 docker 后出现以下错误:

I am trying to run a typescript express.js in a docker container. After running the docker I get the following error:

> 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:

my Dockerfile:

FROM node:alpine

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

CMD ["npm","start"]

还有 package.json 文件:

and the package.json file:

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

附注我决定加入修复:更改 Dockerfile:

P.S. I have decided to include the fix: change the Dockerfile:

FROM node:lts-alpine

并更改 package.json:

and change the package.json:

"start": "ts-node-dev src/app.ts --poll"

推荐答案

Node v14 对 fs.watch() API 进行了重大更改,特别是 recursive选项(Linux 上从未支持过)现在会引发 ERR_FEATURE_UNAVAILABLE_ON_PLATFORM 如果在 Linux 上使用会出错.

Node v14 introduced a breaking change to the fs.watch() API, specifically that the recursive option (which has never been supported on Linux) now raises the ERR_FEATURE_UNAVAILABLE_ON_PLATFORM error if used on Linux.

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

A bug report and fix have been submitted to filewatcher: https://github.com/fgnass/filewatcher/pull/6

在合并该修复并发布新版本之前,您需要坚持使用 NodeJS <v14,或覆盖本地安装的 filewatcher 包以包含该补丁.

Until that fix is merged and a new version released, you'll need to stick to NodeJS < v14, or override the filewatcher package installed locally to include that patch.

这篇关于如何解决:当前平台上递归监视功能不可用,正在用于运行 Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆