AHmedRef
AHmedRef

Reputation: 2611

The dev server never responds when starting an empty project based on NextJs documentation

Based on NextJs framework documentation, I followed some setup steps to run an empty project :

mkdir hello-next
cd hello-next
npm init -y
npm install --save react react-dom next
mkdir pages

Then I added these 3 lines to my package.json file :

 "scripts": {
   "dev": "next",
   "build": "next build",
   "start": "next start"
 }

So right now everything should be ready to make my app run, executing this command line :

npm run dev

But I always get in an endless loading loop on http://localhost:3000.

on my console output :

[ wait ]  starting the development server ...
[ info ]  waiting on http://localhost:3000 ...
[ ready ] compiled successfully (ready on http://localhost:3000)

Upvotes: 3

Views: 884

Answers (1)

Emile Bergeron
Emile Bergeron

Reputation: 17430

You are right, it doesn't work like the tutorial suggests. I opened an issue in the Next Github repository which is now resolved and a fix should be available in the 9.0.1 release.

In the meantime, you can add a simple page by creating a file named index.js or index.jsx in the pages directory and restarting the server.

// pages/index.js
export default () => 'Super simple page';

Then, navigating to http://localhost:3000 should show this page and any other path should show the default Next's 404 error page.

Upvotes: 2

Related Questions