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

Create-react-app在一台Windows设备安装卡顿,另一台正常求助

Fixing Stuck npx create-react-app Installation on Windows

Hey there, sorry to hear you're hitting this roadblock with create-react-app on one of your Windows machines. Since it works fine on another device, the issue is likely specific to the problematic machine's environment. Let’s walk through some targeted fixes that should get you past that stuck Installing react, react-dom, and react-scripts with cra-template... step:

  • Clear npm and npx caches
    Corrupted cache files are a frequent culprit here. Run these commands in your terminal (as administrator if possible):

    npm cache clean --force
    npx clear-npx-cache
    

    Once done, retry the original command: npx create-react-app new

  • Temporarily disable antivirus/firewall
    Windows Defender or third-party security tools sometimes flag npm’s network requests as suspicious and block them, causing the installation to hang. Try turning off your antivirus/firewall temporarily, then run the create-react-app command again. Don’t forget to re-enable them afterward!

  • Switch to a faster npm registry
    If the issue is network-related (slow or blocked access to the default npm registry), switch to a mirror like the npmmirror registry:

    npm config set registry https://registry.npmmirror.com
    

    Then retry the installation command. If you need to switch back later, run:

    npm config set registry https://registry.npmjs.org/
    
  • Manually create the project (bypass npx auto-install)
    If the above steps don’t work, let’s build the project from scratch manually:

    1. Create and navigate to your project folder:
      mkdir new && cd new
      
    2. Initialize npm:
      npm init -y
      
    3. Install the required dependencies directly:
      npm install react react-dom react-scripts cra-template
      
    4. Open your package.json file and replace the default scripts section with this:
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
      }
      
    5. Create public and src folders in your project root. You can copy the default template files from your working Windows machine (the one where create-react-app works) or use basic placeholder files like the standard CRA HTML template for public/index.html and default component files for src.
  • Check user permissions and run terminal as admin
    Sometimes the installation gets stuck because your user account doesn’t have write access to the project directory. Try opening your terminal (Command Prompt or PowerShell) as an administrator, then run the create-react-app command again.

  • Verify proxy settings
    If your machine is on a corporate network with a proxy, npm might be having trouble connecting. Check if a proxy is configured with:

    npm config get proxy
    npm config get https-proxy
    

    If you see proxy URLs here but don’t need them (or they’re incorrect), clear them with:

    npm config delete proxy
    npm config delete https-proxy
    

    If you do need a proxy, set it correctly with your network’s proxy details:

    npm config set proxy http://your-proxy-address:port
    npm config set https-proxy http://your-proxy-address:port
    

Give these steps a try one by one—odds are one of them will resolve the stuck installation issue for you.

内容的提问来源于stack exchange,提问作者Vinkal Chandel

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 07:58:11