score:12

Accepted answer

you have to use npm run dev

these scripts refer to the different stages of developing an application:

dev - runs next dev which starts next.js in development mode

build - runs next build which builds the application for production usage

start - runs next start which starts a next.js production server

source: https://nextjs.org/docs/getting-started

score:0

mine was not working either. my solution:

npm run build
npm start

it worked after doing this.

score:0

fast refresh was broken for us because we were using a custom webpack config in our next.config.js that set react and reactdom as externals.

ensuring both react and reactdom were included in the bundle while in local development fixed the issue for us.

const isdev = node_env === 'development'

module.exports = {
  webpack: config => {
    if (isdev) {
      return config;
    }

    return {
      ...config,
      externals: {
        react: 'react',
        'react-dom': 'reactdom',
      },
    };
  },
};

score:2

you need to add this to package.json

  "scripts": {
    "test": "jest",
    "dev": " next dev -p 8000",
    "build": "next build",
    "start": "next start",
  }

then npm run dev


Related Query

More Query from same tag