I spent this week setting up a public GitHub repo on Windows. Almost every problem came from a tiny detail, and the error messages didn't explain any of them. Here are six, with the fixes.
1. cd /d fails in PowerShell
cd /d C:\Users\me\Desktop\project
Set-Location : A positional parameter cannot be found that accepts argument ...
/d is a Command Prompt option for switching drives. PowerShell doesn't need it. Check your prompt: if it starts with PS, you're in PowerShell, so just run:
cd C:\Users\me\Desktop\project
2. "Cannot find module" usually means "wrong folder"
Error: Cannot find module 'C:\Users\me\evaluate.mjs'
Read the path in the error. It shows the folder your terminal is in, not the folder you meant. Run cd into the project folder, then dir to confirm the file is really there.
3. Downloads quietly rename your files
Download the same file twice and Windows saves evaluate (1).mjs. Your code asks for evaluate.mjs and can't find it. Rename it:
ren "evaluate (1).mjs" evaluate.mjs
4. Notepad saves .gitignore.txt
Windows File Explorer hides file extensions by default, so a stray .txt is invisible. I ended up with both .gitignore and .gitignore.txt, and committed the wrong one by accident.
- Turn on View → Show → File name extensions in Explorer.
- In Notepad's Save As, put the name in quotes (
".gitignore") and set "Save as type" to All files. - Run
dirin the terminal. It shows the real names.
5. git push says "rejected (fetch first)"
! [rejected] main -> main (fetch first)
It means GitHub already has commits your computer doesn't. This usually happens when you tick "Add a README / .gitignore / licence" while creating a repo, and then push your own project. Prevention: create the repo empty. If it's already happened:
git fetch origin
git log origin/main --oneline
Look at what's there. If you want to keep it, merge with git pull origin main --allow-unrelated-histories. If it's only auto-generated starter files you don't need, git push --force-with-lease replaces them, and it refuses if the remote changed since your last fetch. That makes it safer than a plain --force. Never force-push to a repo where other people have real work.
6. A page that calls an API can't be opened by double-clicking
Opening index.html from your folder gives it an address starting with file://. If the page fetches data from a local server, you get Failed to fetch. Start the server, then visit http://localhost:PORT in the browser.
Bonus: check before your first git add .
- Write
.gitignorefirst. Adding a file to.gitignoreafter you've committed it doesn't remove it from history. - Run
git statusbefore committing and read the list. Anything private (data files,.env, exports) shouldn't be there.
None of these took long to fix, but each one cost me ten minutes of confusion. Hopefully this saves someone else those minutes.
Top comments (0)