How to fix Next.js Vercel deployment module not found error

This answer worked for me: https://stackoverflow.com/a/55541435/3051080

TL;DR; update git cache:

git rm -r --cached .
git add --all .
git commit -a -m "Versioning untracked files"
git push origin master

This error typically happens if you're accidentally committing node_modules to your project's Git Repostiory.

Could you try to do the following?

  1. Ensure all changes have been committed and you have a clean directory.
  2. Run rm -rf node_modules (or delete the folder on Windows).
  3. Run git add -A then git commit -m "Remove all module files".
  4. Add node_modules to your .gitignore file (and save).
  5. Run git add -A then git commit -m "Update ignored files".
  6. Verify your directory is completely clean via git status.
  7. Then, run git push. This deployment should work on Vercel.
  8. Finally, re-run npm i or yarn depending on your package manager to get your local copy working.

I had to edit my package.json to use the next binary that ships in the node_modules/next directory:

"scripts": {
  "start": "node_modules/next/dist/bin/next start -p $PORT"
}

Not the most elegant fix but it works.