1

I'm trying to deploy Next.js application in AWS Amplify - But I'm getting this error

I tried solutions mentioned on gitub, which was having the solution for similar error, but it didn' resolve.

Solution 1

npm list lightningcss
npm dedupe
npm rebuild lightningcss

Solution 2

  1. Deleted package-lock
  2. Reinstalled packages
  3. Also tried adding lightningcss.linux-x64-gnu.node package manually into dependency - but still didnt work.

Below error received in AWS amplify for Next.js application

Error: Cannot find module '../lightningcss.linux-x64-gnu.node'
.
.
.
2025-04-14T18:08:53.428Z [WARNING]: > Build failed because of webpack errors

1 Answer 1

0

I was working on a Next.js application and encountered the same error. I followed the same steps you did, but it still didn’t resolve the issue.
So, I removed the experimental feature from the next.config.ts file called turbopackFileSystemCacheForDev: true.
There’s a similar command for the build, turbopackFileSystemCacheForBuild: true, which could have been causing the problem since it’s still in the beta phase at the time of writing this.
After remove that, my project ran successfully.

But that's not all. Even though it worked, I didn't understand why. So, I checked the Next.js docs and found out that the turbopackFileSystemCache saves and restores data to the .next folder. If you clean this folder, it will be regenerated when the build or run command is executed.
This means the .next folder contained corrupted data. After this, I didn't need to remove the experimental feature—it works for me now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.