Error: Node Sass does not yet support your current environment

Error: Node Sass does not yet support your current environment

当我在 Fedora 32 中使用命令 yarn start 启动我的 React 项目时,它显示如下错误:

./src/style/base.scss (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/style/base.scss)
Error: Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (93)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.14.1

我当前的节点版本是:

[dolphin@MiWiFi-R4CM-srv]~/Documents/GitHub/react-admin% nvm list
        v8.17.0
       v10.24.1
->     v16.13.0
        v17.2.0
         system
default -> 8 (-> v8.17.0)

我试过不同版本的node但没有解决这个问题,为什么会这样?我应该怎么做才能解决这个问题?我在 package.json 中没有找到 node-sass 的任何包依赖项,这是 package.json 文件:

{
    "name": "react-admin",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "@ant-design/compatible": "1.0.8",
        "animate.css": "^3.7.2",
        "antd": "^4.0.0",
        "axios": "^0.19.0",
        "braft-editor": "^2.3.8",
        "echarts": "^4.4.0",
        "is-core-module": "2.2.0",
        "moment": "2.29.1",
        "nprogress": "^0.2.0",
        "react": "^17.0.2",
        "react-dom": "^17.0.2",
        "react-highlight-words": "0.17.0",
        "react-loadable": "^5.5.0",
        "react-redux": "^7.1.1",
        "react-router-dom": "^5.1.1",
        "react-scripts": "^3.2.0",
        "redux": "^4.0.4",
        "redux-logger": "3.0.6",
        "redux-promise-middleware": "^6.1.2",
        "redux-thunk": "^2.3.0",
        "screenfull": "^5.0.0"
    },
    "scripts": {
        "start": "react-app-rewired start",
        "build": "CI=false && react-app-rewired build",
        "test": "react-app-rewired test",
        "eject": "react-scripts eject"
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "browserslist": {
        "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ],
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    },
    "husky": {
        "hooks": {
            "pre-commit": "lint-staged"
        }
    },
    "lint-staged": {
        "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
            "node_modules/.bin/prettier --write",
            "git add"
        ],
        "src/**/*.{css,scss,less,json,html,md,markdown}": [
            "node_modules/.bin/prettier --write",
            "git add"
        ]
    },
    "devDependencies": {
        "@babel/helper-builder-react-jsx": "^7.12.13",
        "babel-plugin-import": "^1.12.2",
        "customize-cra": "^0.8.0",
        "husky": "^3.0.9",
        "lint-staged": "^9.4.2",
        "sass": "1.37.0",
        "prettier": "^1.18.2",
        "react-app-rewired": "^2.1.4"
    }
}

第一个解决方案

确保您的 nodejs.js version is not superior than the latest stable version, which is currently v16.15.0. Then you would wanna use sass package instead of node-sass,因为它已被弃用。做的事:

npm uninstall node-sass --save
npm install sass --save

第二种解决方案

如果您出于某种原因需要或想要 node-sass,您应该将 nodes.js 版本降级为喜欢 v14。为此,您可以使用 npm 中的 n 包,如下所示:

npm install -g n
n 14
# if one of the commands does not pass, you may need to use sudo
sudo npm install -g n
sudo n 14