fsevents@2.3.2 不受支持的平台:需要 {"os":"darwin","arch":"any"}(当前:{"os":"linux" ,"arch":"x64"}) 在 github 个动作上

Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) on github actions

我已经创建了一个 github 操作来在推送时部署代码。

安装软件包时会导致此错误。

Run npm i --no-optional && cd client && npm i --no-optional && cd ..
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  any
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:

我知道问题出在 fsevents 上。 linux 不支持它。但我安装了这个包。它在我的 package.json

中不可用
    "devDependencies": {
        "@babel/cli": "^7.12.1",
        "@babel/core": "^7.14.0",
        "@babel/node": "^7.13.13",
        "@babel/plugin-transform-runtime": "^7.13.15",
        "@babel/preset-env": "^7.14.1",
        "@types/react-router-dom": "^5.1.7",
        "@types/styled-components": "^5.1.10",
        "antd": "^4.16.2",
        "cross-env": "^7.0.3",
        "eslint": "^7.25.0",
        "eslint-config-prettier": "^8.3.0",
        "eslint-plugin-prettier": "^3.4.0",
        "eslint-plugin-react": "^7.24.0",
        "morgan": "^1.10.0",
        "nodemon": "^2.0.7",
        "prettier": "^2.2.1",
        "react-awesome-reveal": "^3.8.1",
        "react-i18next": "^11.10.0",
        "styled-components": "^5.3.0"
    },
    "dependencies": {
        "@babel/register": "^7.13.16",
        "@babel/runtime": "^7.14.0",
        "bcrypt": "^5.0.1",
        "cookie-parser": "^1.4.5",
        "cors": "^2.8.5",
        "debug": "^4.3.1",
        "dotenv": "^9.0.0",
        "express": "^4.17.1",
        "express-async-handler": "^1.1.4",
        "joi": "^17.4.0",
        "joi-password-complexity": "^5.1.0",
        "jsonwebtoken": "^8.5.1",
        "mongoose": "^5.12.7",
        "object-hash": "^2.1.1",
        "passport": "^0.4.1",
        "passport-jwt": "^4.0.0",
        "passport-local": "^1.0.0",
        "react-autosuggest": "^10.1.0",
        "validator": "^13.6.0"
    }

我尝试在 npm i 时添加非可选参数。并将 fsevent 添加到可选依赖项中。仍然导致同样的错误。

我也有类似的情况,是nodemon引起的。不得不恢复到 nodemon v1.19.4

我在使用 GitHub 操作任务在 Azure 静态 Web 应用程序中部署 Vue 应用程序时遇到了这个问题。

运行 npm audit fix 并推动更改 package-lock.json 为我解决了。

你必须删除 package.lock.json 而不是使用 npm i