【问题标题】:react-script problem while having a node_module folder in the parent directory在父目录中有 node_module 文件夹时出现反应脚本问题
【发布时间】:2019-04-16 08:53:21
【问题描述】:

我的项目的父文件夹中有另一个 node_module 文件夹。我将 react-script 更新为 v2,在尝试启动项目时出现如下错误:

The react-scripts package provided by Create React App requires a dependency:

  "webpack": "4.19.1"

Don't try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:

  /parent_dir/node_modules/webpack (version: 4.20.2)

但是,我的项目在这个目录下,并且有自己的 node_module 文件夹:

  /parent_dir/my_project/node_modules/webpack (version: 4.20.2)

如果我删除父母的 node_modules,一切都会好起来的!

【问题讨论】:

    标签: reactjs node-modules create-react-app react-scripts


    【解决方案1】:

    我知道这是有意的。我们可以使用 react-scripts repo 文档中提供的说明跳过预检检查以解决问题。但是,我仍然不知道这次飞行前检查的原因是什么。

    【讨论】:

    • 同意,我不明白为什么 webpack 在父文件夹中对 react-scripts 很重要
    • @BenClayton 来自 Dan Abramov:我们经常收到错误报告,其中 npm 产生了错误的安装(例如,与 yarn 混合时)并导致插件找到错误的 webpack 并失败并出现非常令人困惑的错误。
    猜你喜欢
    • 2023-01-19
    • 1970-01-01
    • 2020-03-22
    • 2015-02-24
    • 1970-01-01
    • 2011-12-30
    • 1970-01-01
    • 2011-11-20
    • 1970-01-01
    相关资源
    最近更新 更多