Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newly created Next.js app giving error URL.canParse is not a function

I have created Next.js app by the command npx create-next-app@latest after running it npm run dev, I am getting below error.

Uncaught TypeError: URL.canParse is not a function at getSocketUrl (webpack-internal:///(:3001/app-pages-browser)/./node_modules/next/dist/client/components/react-dev-overlay/internal/helpers/get-socket-url.js:23:13)

The app is created with Next.js version 14.2.11

I have tried to fix it by following suggestions provided by ChatGpt with no success. Tried below solutions

npm update next react react-dom

Clear Cache - rm -rf .next

Restart server - npm run dev

like image 282
mujaffars Avatar asked Aug 10 '26 08:08

mujaffars


2 Answers

Downgrading nextjs version to 14.2.10 works.

like image 55
Xavier Rincon Rico Avatar answered Aug 11 '26 22:08

Xavier Rincon Rico


A similiar issue suggest checking/updating your node-version as well as upgrading @types/node. This might work for you, too.

According to Node.js URL.canParse was added in: v19.9.0, v18.17.0.

You can run node -v in your terminal to check your current Node version.

like image 24
Carsten Codes Avatar answered Aug 11 '26 22:08

Carsten Codes