I just created a new site from the Nextjs blog template and I’m having trouble when I run “npm run build”. Using the template with no modifications, I can deploy just fine, but when I run the build locally I get this error:
Failed to compile.
Module not found: Can’t resolve ‘…/styles/globals.css’ in ‘C:\Users\williamsjohn\git\nextjs-blog\pages’
> Build failed because of webpack errors
If I change the import to in
./styles/globals.css, the build works locally but fails when I deploy. The strange thing is that when I look at the deployment log, it seems to be using the exact same build command I’m running for local builds. I can work around the issue by leaving
pages/_app.js alone and copying
styles/globals.css, but that seems pretty hacky and definitely not something I should have to do.
My site name is
johnwillia-ms.netlify.app, and the github repo is at GitHub - johnw42/johnwillia-ms