<p>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.</p>
<p>I stucks at creating an optimized build ... I did not even get any error.</p>
<p>I cloned the next.js repo and added some console.logs and build it and replaced the built files in my project's <code>node_modeules</code> directory.</p>
<p>I am able to figure out that the execution is stuck at line 42 on <a href="https://github.com/vercel/next.js/blob/8d84b08752c5abbfcc90c34aa3b010253fd478c5/packages/next/build/compiler.ts" rel="nofollow noreferrer">compiler.ts</a></p>
<p>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</p>
<p>Any experts of webpack or next.js contributors please help.</p>

Mayank Kumar Chaudhari
<p>I am sharing some observations in case someone facing similar issues stumbles upon this post.</p>
<p>After reading many articles and q&amp;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 <code>my-app</code> and <code>common-sass</code> directories inside the pod and the source code inside <code>my-app</code> was importing scss from <code>common-sass</code>.</p>
<p>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 <code>node.js</code> not allowed to access anything outside of the directory containing the source code. (This was not a problem in my local minikube pod)</p>
<p>I moved all markdown inside and now it is moving ahead of where it was stuck. But now I get error saying <code>fs not defined</code>. Well I explored bit more and figured out that I can use fs only inside <code>getStaticProps</code>.</p>
<p>Fixed that too. But One of the packages that I am using - <code>next-optimised-images</code> - uses fs and now compiler is complaining about that.</p>
<p>This does not fully solve my problem but at least will give some direction to someone facing similar issues.</p>
