ilkerunal
ilkerunal

Reputation: 31

Generated next js chunks does not load on local environment

I recently joined a project written with Next Js and Squidex CMS. The problem is I am not able to run it (properly) on my local environment. The chunks are not loading and the images are not visible

I tried 2 ways

1 - Running the project with the same scripts on production pipeline

- clean `node_modules` and `.next` directories
- run `yarn build`
- run `yarn start`

The build is always successful but when I try to run the build by yarn start it does not load some js chunks and assets (images in static folder)

They are throwing 404 error on the console (please see the image) I compared the hashes and they are fine.

My next config file is pretty empty.

const optimizedImages = require("next-optimized-images")
const withPlugins = require("next-compose-plugins")

module.exports = withPlugins([
        [optimizedImages, {
        responsive: {
                adapter: require('responsive-loader/sharp')
            }
        }]
    ], 
    
)

I also tried with multiple next versions (9.5.0 and 10.1.3)

enter image description here

Upvotes: 1

Views: 1389

Answers (1)

ilkerunal
ilkerunal

Reputation: 31

The issue was the directory name of the project. Repository named like 'Some Project' and when you try to clone it via SSH provided from repository website, the directory on your computer will be like this : 'Some%20Project'

Example ssh command : [email protected]:Some%20Project

In that case, node.js server able to start and there is no error on the console unless you launch your browser and try to react the localhost. Node.js is not able to serve files from the directory because of not supported string chars like %

This cost me a lot of hours to find out, hope it will help

Upvotes: 1

Related Questions