Windows 10下使用Yarn发布至gh-pages失败求助
I ran into a similar issue before on Windows—this error happens because Windows' command line (either Command Prompt or PowerShell) handles quotes and wildcard syntax differently than Unix-based shells. The single quotes around your --dist and --src arguments are being treated as part of the actual path, and the {} brace expansion isn't recognized, leading to that broken path '.' the system can't find.
Here are a couple of proven fixes:
1. Update the Script with Windows-Friendly Syntax
Modify your package.json script to use double quotes (escaped with \" since it's JSON) and replace the brace expansion with space-separated paths:
"scripts": { "gh-pages": "gh-pages --dist . --src \"index.html dist/** CNAME\"" }
This tells Windows to properly parse the paths without treating quotes as part of the file location, and gh-pages will correctly pick up the files you want to publish.
2. Simplify the Command (Optional)
If your goal is to publish exactly those three items from the root directory, you can even omit the --dist flag (gh-pages defaults to working with the current directory when using --src):
"scripts": { "gh-pages": "gh-pages --src \"index.html dist/** CNAME\"" }
Quick Checks to Rule Out Other Issues
- Double-check that
CNAMEexists in your project root (note: gh-pages requires this filename to be uppercase, so make sure it's notcname). - Ensure there are no typos in the file/directory names you're targeting.
After updating the script, run yarn gh-pages again—it should work without the ENOENT error.
内容的提问来源于stack exchange,提问作者mahboub_mo

