Can't solve "Error: Node Sass version 7.0.1 is incompatible with ^4.0.0"

Can't solve "Error: Node Sass version 7.0.1 is incompatible with ^4.0.0"

我已经尝试了很多解决方案来解决这个错误,但没有任何效果。我卸载了 sass 和 node-sass 几次,我更新到我认为是最新版本的 sass 和 sass-loader 无济于事。难道我做错了什么?我的 JSON 文件在下面。

{
  "name": "w18-final-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "node": "^17.7.2",
    "node-sass": "^7.0.1",
    "react": "^18.1.0",
    "react-dom": "^18.1.0",
    "react-script": "^2.0.5",
    "react-scripts": "^2.1.3",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts --openssl-legacy-provider start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

感谢您的建议!以下工作:

  1. npm 卸载 node-sass

  2. npm i -D sass

现在它编译并运行得非常棒!