VSCode崩溃后执行npm start时React项目运行在异常URL的问题求助
Hey Bryan, sorry to hear you ran into this weird glitch after VSCode crashed on you. Let's walk through some practical fixes that should get your app back up and running normally:
1. Wipe Dev Server & Dependency Caches
Corrupted caches are a common culprit here—let's start fresh:
- Stop your running
npm startprocess withCtrl + Cin the terminal - Delete your
node_modulesfolder,package-lock.json(oryarn.lockif you use Yarn) from the project root - Run
npm installto reinstall clean dependencies - Fire up
npm startagain and check if the URL is back tohttp://localhost:3000
2. Check for Misconfigured Environment Variables
React uses the PUBLIC_URL variable to set your app's base path, which might have gotten messed up during the crash:
- Look for a
.envfile in your project root - If you see a line like
PUBLIC_URL="/bryansomto/appName", change it toPUBLIC_URL="/"or delete the line entirely - Restart your dev server after making this tweak
3. Clear Browser Cache & Local Storage
Your browser might be clinging to old routing data that's causing the blank page:
- Open your browser's dev tools (
F12orCtrl+Shift+I) - Head to the Application tab
- Under Storage, click "Clear site data" to wipe cache, cookies, and local storage
- Do a hard refresh (
Ctrl+Shift+R) on the page afterward
4. Verify React Router Configuration (If You Use It)
If you're using React Router, double-check that the base path wasn't accidentally modified:
- Find where you render
BrowserRouterin your app - If it has a
basenameprop set to"/bryansomto/appName", remove that prop or set it tobasename="/" - Example of the corrected code:
<BrowserRouter basename="/"> {/* Your routes go here */} </BrowserRouter>
5. Reset VSCode Workspace State
VSCode crashes can leave wonky hidden workspace settings behind:
- Close VSCode completely
- Locate the
.vscodefolder in your project root (it's hidden by default) - Rename it to
.vscode-oldor delete it entirely - Reopen VSCode and your project, then run
npm startagain
If none of these work, quickly check your public/index.html to make sure there are no hardcoded paths pointing to /bryansomto/appName—that's a rare but possible issue.
内容的提问来源于stack exchange,提问作者Bryan Somto

