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
相关产品推荐
相关产品推荐

