create-react-app 将react-scripts从4.0.0更新到5.0.1会导致SCSS导入和ESLint错误,

iswrvxsc  于 2个月前  发布在  React
关注(0)|答案(1)|浏览(30)

描述bug

我想将 react-scripts 从 v4.0.0 升级到 5.0.1,以减少项目中的漏洞数量。在这样做的过程中,我遇到了与 SCSS 和 ESLint 相关的错误:

你尝试恢复依赖关系了吗?

是的,NPM 版本:9.2.0

你在用户指南中搜索了哪些术语?

"react-scripts scss"

环境

Environment Info:

  current version of create-react-app: 5.0.1
  running from /Users/anishkshatriya/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app

  System:
    OS: macOS 12.6.1
    CPU: (8) x64 Apple M1 Pro
  Binaries:
    Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 9.2.0 - ~/.nvm/versions/node/v14.18.1/bin/npm
  Browsers:
    Chrome: 108.0.5359.124
    Edge: Not Found
    Firefox: 108.0
    Safari: 16.2
  npmPackages:
    react: ^17.0.1 => 17.0.1 
    react-dom: ^17.0.1 => 17.0.1 
    react-scripts: ^5.0.1 => 5.0.1 
  npmGlobalPackages:
    create-react-app: Not Found

重现步骤

(在这里写下你的步骤:)

  1. 安装 react-scripts v5.0.1
  2. 启动开发服务器,错误立即出现在控制台

预期行为

(写出你认为会发生什么。)
预期行为是这些 SCSS 和 ESLint 错误不会出现。

实际行为

请查看上述错误的截图。

eqfvzcg8

eqfvzcg81#

我今天在将 react-scripts 从 4.0.2 升级到 5.0.1 时遇到了这个 ESLint 错误。

Oops! Something went wrong! :(

ESLint: 7.32.0

ESLint couldn't find the config "react-app" to extend from. Please check that the name of the config is correct.

The config "react-app" was referenced from the config file in "C:\...\package.json".

对我来说,一个有效的解决方法是安装这些包:

npm i -D eslint eslint-config-react-app --legacy-peer-deps

虽然看起来有些多余,但我的应用程序现在按照预期工作了。

相关问题