Reputation: 18538
I am facing quite a strange issue. I have next.js app running inside docker container. On local ubuntu machine, the docker containers are orchestrated using minikube and ks8 and it builds just fine. But on staging setup the build hangs or it is stuck forever.
I stucks at creating an optimized build ... I did not even get any error.
I cloned the next.js repo and added some console.logs and build it and replaced the built files in my project's node_modeules
directory.
I am able to figure out that the execution is stuck at line 42 on compiler.ts
I don't get any logs after this line and therefore know that the process is stuck here and it remains stuck there for hours. Not able to figure out why is this happening
Any experts of webpack or next.js contributors please help.
Upvotes: 0
Views: 349
Reputation: 18538
I am sharing some observations in case someone facing similar issues stumbles upon this post.
After reading many articles and q&a on StackOverflow as well as other forums I understood that ks8 on google does not allow to import scss from outside the project directory. In our case we had some common scss shared between projects that we kept outside the folder containing the source. it was like my-app
and common-sass
directories inside the pod and the source code inside my-app
was importing scss from common-sass
.
I fixed that and moved the sass files within the project directory. However, I still had same issues. Then I realized that I was importing not only sass, but I was also reading markdown files from outside the project directory and probably node.js
not allowed to access anything outside of the directory containing the source code. (This was not a problem in my local minikube pod)
I moved all markdown inside and now it is moving ahead of where it was stuck. But now I get error saying fs not defined
. Well I explored bit more and figured out that I can use fs only inside getStaticProps
.
Fixed that too. But One of the packages that I am using - next-optimised-images
- uses fs and now compiler is complaining about that.
This does not fully solve my problem but at least will give some direction to someone facing similar issues.
Upvotes: 1