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
2
Answers
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.downgrade nextjs version from "next": "14.2.11" to "next": "14.2.10" and "eslint-config-next": "14.2.11" to "eslint-config-next": "14.2.11" downgrading to stable nextjs version works whenever installing a new nextjs project