Netlify build error: cannot find module

What’d you do if this happens to you:
During deployments on netlify, the build process fails consistently with an error message stating "Build failed: Cannot find module ‘xyz-package’ ". The package question is correctly listed in the package.json file. how can it be fixed?

Thanks for writing in!

It appears that this might be working properly locally? If so, it’s possible some things may have gotten tangled between your local package-lock file and the one that the Netlify deploy is using.

Can you try deleting your local node_modules (and package-lock.json), reinstalling the packages, and pushing those new files back up to Netlify?

1 Like