Home > Enterprise >  localhost:3000 front end not loading on NextJS app
localhost:3000 front end not loading on NextJS app

Time:07-30

New React developer here. I have an eCommerce application I've been working through (Strapi backend, Next frontend), I'm having a lot of trouble when it comes to loading the front end on localhost.

I run the backend with npm start on localhost:1337, loads fine. I then try to run the front end with npm run dev, however, localhost:3000 doesn't load. Previously, my localhost:3000 was in use by a Razer server which I would terminate, however, this fix doesn't seem to work anymore.

I've tried updating my package.json file as below to load the frontend on a different port.

  "scripts": {
    "dev": "set PORT=3008 && next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },

I've also tried netstat as below in cmd which didn't return any results

netstat -a -o | find "3008"

I've checked Porthog to see if port 3000/3008 are in use after starting my front end, and each time the below is shown.

PORT      PID       PROCESS
--------------------------------------------------
3000      -         -

As a last resort, I have also restarted my PC multiple times.

Feeling a bit defeated so any help is appreciated, thank you.

CodePudding user response:

The error you provided is actually a compile-time error, which means it'll completely stop the development server. You'll have to fix the error before being able to run the dev server.

A good way to check whether your dev server has stopped is whether you see the terminal prompt (in your case, PS (path)>). If it's running, it won't have that, and your last log should be something along the lines of compiled / successfully.

  • Related