You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React 16.2项目安装prop-types后出现Cannot find module 'react-dev-utils/clearConsole'错误求助

Fixing "Cannot find module 'react-dev-utils/clearConsole'" in React 16.2 Project

Hey there, let's work through this error step by step! This issue typically crops up due to dependency mismatches or corrupted installation files after adding prop-types to your React 16.2 project. Here are actionable solutions to get your app running again:

1. Install or Reinstall react-dev-utils

The react-dev-utils package is a critical development dependency (usually bundled with react-scripts), and it might have been missing or corrupted during your prop-types install. Run this command to add it explicitly:

npm install react-dev-utils --save-dev

2. Clean Cache and Reinstall All Dependencies

Sometimes cached files or broken dependency trees cause this error. Follow these steps to do a fresh install:

  • Delete the node_modules folder and package-lock.json file:
    # For macOS/Linux
    rm -rf node_modules package-lock.json
    
    # For Windows (Command Prompt)
    rmdir /s /q node_modules
    del package-lock.json
    
  • Clear your npm cache to remove any corrupted cached packages:
    npm cache clean --force
    
  • Reinstall all dependencies from scratch:
    npm install
    

3. Ensure Compatibility with react-scripts

React 16.2 works best with specific versions of react-scripts (the v2.x series, since newer versions drop support for older React releases). If your react-scripts version is too new or outdated, install a compatible version:

npm install react-scripts@2.1.8 --save-dev

This version is known to play nicely with React 16.2 and includes the correct react-dev-utils dependency.

4. Verify Dependency Versions

Double-check your package.json to confirm:

  • react is set to ^16.2.0
  • react-scripts matches the compatible version you installed
  • react-dev-utils is listed under devDependencies

If you still run into issues, try deleting the package-lock.json again and repeating the reinstall step—sometimes lock files can hold onto outdated or conflicting dependency references.

内容的提问来源于stack exchange,提问作者azmul hossain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 03:30:03