reactjs fsevents@2.3.2安装问题不支持的平台

yyyllmsg  于 2023-04-20  发布在  React
关注(0)|答案(3)|浏览(189)

我一直在尝试将我的应用程序部署到vercel上,并且已经阅读了stackoverflow上的许多帖子,这些帖子都有相同/类似的fsevents问题。
我尝试过的事情:

  • 卸载node_modulespackage-lock.json,然后运行:npm i -f
  • 加上"optionalDependencies": {"fsevents": "^2.3.2"},然后是npm i -f
  • package.json中不安装fsevents
  • 。。。以及许多其他的尝试

部署中经常发生的情况的屏幕截图

我不太熟悉整个fsevents/chokidar包的内容/原因,但在我阅读完之后,我的MacOS似乎需要它,我真的很感激一些解决这个问题的想法。

当前package.json

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "eslint .",
    "lint:fix": "eslint --fix ."
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx}": [
      "prettier --write",
      "eslint --fix ."
    ]
  },
  "dependencies": {
    "firebase": "^8.2.5",
    "firebase-admin": "^9.4.2",
    "firebase-functions": "^3.13.1",
    "fsevents": "^2.3.2",
    "js-cookies": "^1.0.4",
    "next": "10.0.6",
    "next-pwa": "^5.0.5",
    "nookies": "^2.5.2",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-redux": "^7.2.2",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "styled-components": "^5.2.1"
  },
  "optionalDependencies": {
    "fsevents": "^2.3.2"
  },
  "devDependencies": {
    "@types/node": "^14.14.25",
    "@types/react": "^17.0.1",
    "@types/react-redux": "^7.1.16",
    "@types/styled-components": "^5.1.7",
    "babel-eslint": "^9.0.0",
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-nextjs": "^1.0.7",
    "eslint-config-prettier": "^4.3.0",
    "eslint-plugin-html": "^5.0.5",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.3.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^1.7.0",
    "husky": "^4.3.8",
    "lint-staged": "^10.5.3",
    "prettier": "^1.19.1",
    "redux-devtools-extension": "^2.13.8",
    "typescript": "^4.1.3",
    "webpack": "^5.21.1"
  }
}
r6hnlfcb

r6hnlfcb1#

很多人抱怨这是几年前的事了。
有时修复是升级到较新的npm.(运行npm 7.7和仍然有它)
通常解决方法就是

npm install -f

所以强迫它在这里很有效

ddrv8njm

ddrv8njm2#

我们遇到了同样的问题,因为在团队中我们有不同的操作系统类型Linux/MacOS/Windows,我手动编辑了package-lock.json并添加了不同的操作系统类型

"node_modules/fsevents": {
  ...
  "os": [
        "darwin",
        "win32",
        "linux"
      ],
  ...
}

之后,我运行npm install

tsm1rwdh

tsm1rwdh3#

如果有人在旧版本的Node / npm上遇到这些错误,最好的选择可能是升级。

node --version

如果(截至2023年)它的输出小于16.x,您可能需要升级。
将节点安装/更新到最新的LTS版本:https://nodejs.org/en/download,这些错误应该被修复。

相关问题