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

WSL(Ubuntu)中npx本地安装包异常问题求助

WSL Ubuntu下npx create-react-app无法运行的解决方法

排查与修复步骤

  • 检查Node.js和npx版本:运行node -v和npx -v,确保Node.js版本在14.0.0以上。版本过低的话,用nvm安装稳定版:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    source ~/.bashrc
    nvm install --lts
    
  • 清除缓存解决损坏问题:
    npx clear-npx-cache
    npm cache clean --force
    
  • 强制使用最新版create-react-app执行:
    npx create-react-app@latest my-app
    
  • 检查目录权限:确保当前用户对要创建项目的目录有读写权限,避免用sudo创建目录导致权限冲突。
  • 验证网络与镜像:执行ping npmjs.com测试网络连通性,若访问缓慢,切换国内镜像:
    npm config set registry https://registry.npmmirror.com
    

额外方案

如果之前全局安装过create-react-app,可能存在版本兼容问题,先卸载全局包再重试:

npm uninstall -g create-react-app

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 05:03:12