gpt4 book ai didi

node.js - Node Sass 版本 7.0.1 与 Mac 中 React 中的 ^4.0.0 不兼容

转载 作者:行者123 更新时间:2023-12-05 01:04:15 28 4
gpt4 key购买 nike

我认为我正在使用适当的 node/npm/node-sass 版本,但我仍然收到此错误 - “Node Sass 版本 7.0.1 与 ^4.0.0 不兼容”同时运行 npm start评论。我不确定这个 4.0.0 版本是什么。它不在我下面给出的任何版本中。

以下是安装版本

Node version - 16.15.0
NPM version - 8.11.0
Node Sass version - 7.0.1

下面是package.json

{
"name": "test-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"http-proxy-middleware": "^1.0.6",
"node-sass": "^7.0.1",
"normalize-scss": "^7.0.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^2.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts 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"
]
},
"devDependencies": {
"sass": "^1.52.1"
}
}

谁能猜出是什么导致了不兼容的问题?

最佳答案

这是您的 sass-loader 版本不兼容。您可以通过以下方式查看您正在使用的版本:

node_modules > sass-loader > package.json

然后阅读"version"旁边写的内容。


你的项目使用了 CRA,这意味着它是 react-scripts 处理 sass-loader。更新您的 react-scripts 版本应该可以解决问题。

由于您使用的是旧版本,我建议您逐步进行更新。您可以从 v3.0.0 开始然后 v4.0.0最后是 v5.0.0 .

不要忘记阅读每个版本的重大更改,因为它们可能会破坏代码的其他部分。


您还需要知道 Node Sass is deprecated你应该尝试使用 Dart Sass。

关于node.js - Node Sass 版本 7.0.1 与 Mac 中 React 中的 ^4.0.0 不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72446649/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com