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

系统用户名含空格导致Yarn创建Next.js应用报错,如何成功执行命令?

Fix: Yarn Create Next.js App Fails Due to Space in Windows Username

Got it, this is a super common headache on Windows when your user directory has spaces—command-line tools like CMD split paths at spaces by default, which is exactly what’s happening here: your path C:\Users\Yatharth Singh is getting chopped into C:\Users\Yatharth and Singh\..., so the shell can’t locate the full create-next-app executable.

Here are three reliable fixes, ordered from easiest to most invasive:

1. Switch to PowerShell

PowerShell handles paths with spaces way more intelligently than traditional CMD. Just open PowerShell and run your original command directly:

yarn create next-app panda

It automatically wraps space-containing paths in quotes behind the scenes, so this should work without any extra tweaks.

2. Use Windows Short Path (8.3 Format)

Windows generates a shortened, space-free version of every directory name (called 8.3 format). Here’s how to use it:

  • Open CMD and run this command to find your user directory’s short name:
    dir /x C:\Users
    
    Look for the entry matching Yatharth Singh—it’ll be something like YATHAR~1 (the exact name might vary, but it’ll be 6 characters plus ~1).
  • Use this short path to run the create command:
    C:\Users\YATHAR~1\AppData\Local\Yarn\bin\create-next-app panda
    
    Or if you prefer using yarn create:
    yarn create next-app panda --command "\"C:\Users\YATHAR~1\AppData\Local\Yarn\bin\create-next-app\""
    

3. Manually Wrap the Path in Quotes (For CMD)

If you want to stick with CMD, explicitly wrap the full create-next-app path in double quotes, escaping the inner quotes with backslashes:

yarn create next-app panda --command "\"C:\Users\Yatharth Singh\AppData\Local\Yarn\bin\create-next-app\""

This tells CMD to treat the entire string as a single path, not split it at the space.

Skip renaming your user directory as a first fix—it’s a hassle and can break existing software that relies on the original path.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.28 10:47:47