Next JS npm start app load 404 page not found error for physical pages

Elvin Mammadov picture Elvin Mammadov · Feb 9, 2020 · Viewed 7.5k times · Source

My project works well with run dev command but when I try to npm start I got 404 page not found error for other pages (pages/...) except Index.js.

I tried several ways which I found from forms(gthub issues, and blogs), but nothing worked.

Any Idea? Actually why there should be difference between run dev and start? I think we should see whats wrong in our app during the dev process

the scripts from package.json

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

},

and next.config.js

const withCSS = require("@zeit/next-css");
module.exports = withCSS({
  cssModules: true,
  cssLoaderOptions: {
    importLoaders: 1,
    localIdentName: "[local]___[hash:base64:5]"
  }});

As you see I didn't change anything after installing nextJS.

enter image description here enter image description here

Answer

Gaurav Goyal picture Gaurav Goyal · Mar 16, 2020

I found out that if the filenames have uppercase letters on Windows, you get a 404 error.

I changed all filenames to lowercase characters and the 404 errors went away.