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

使用create-react-app时遭遇ENOENT错误求助(Windows10环境)

Troubleshooting ENOENT Error with create-react-app on Windows 10

Hey there, sorry to hear you're stuck with this ENOENT error while trying to get started with React—totally frustrating when you're just trying to follow a tutorial! Let's go through some additional troubleshooting steps that might help since you've already knocked out the common fixes:

  • Clean up npm cache and global packages
    First, clear out any cached files that might be corrupted:

    npm cache clean --force
    

    Then, make sure you don't have a global installation of create-react-app conflicting with npx's latest version:

    npm uninstall -g create-react-app
    

    Now try creating your project again with the explicit latest version flag:

    npx create-react-app@latest my-react-app
    
  • Verify directory permissions and paths
    Even if you tried the user folder, double-check that your user account has full read/write access to the folder you're working in:

    1. Right-click your target folder → Properties → Security
    2. Select your user account and ensure "Full Control" is enabled
      Also, avoid paths with special characters (spaces, non-English letters) — stick to simple paths like C:\Users\YourName\my-app.
  • Check Node.js environment variables

    1. Open System Properties → Advanced → Environment Variables
    2. In both User Variables and System Variables, confirm the PATH includes your Node.js installation folder (usually C:\Program Files\nodejs\)
    3. Remove any suspicious paths that might reference old Node.js instances (like leftover Adobe-related entries)
      Restart your terminal after making changes to apply the updates.
  • Try a fresh PowerShell session with script permissions
    Open PowerShell as Administrator and run this first to allow script execution:

    Set-ExecutionPolicy RemoteSigned
    

    Press Y to confirm, then try running the npx create-react-app command again in this session.

  • Temporarily disable security tools
    Sometimes Windows Defender or third-party antivirus software can block npm from creating files, triggering ENOENT errors. Disable these tools temporarily, attempt to create your project, then re-enable them once it's successful.

  • Manually build the project structure (last resort)
    If all else fails, you can replicate the create-react-app setup manually:

    1. Create a new folder, navigate into it, and initialize a package.json:
      npm init -y
      
    2. Install required dependencies:
      npm install react react-dom
      npm install --save-dev react-scripts
      
    3. Update the scripts section in your package.json to match:
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
      }
      
    4. Create public and src folders:
      • Add an index.html in public (use the basic template from React's official docs)
      • Add App.js and index.js in src with the default React starter code

内容的提问来源于stack exchange,提问作者Fisheye Wout

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:07:40