Repo: https://github.com/vortextemporum/BoringBananasCompany

I added Infura node provider to the config.js

Deploying to Netlify using

yarn build

build dir: build

It works fine off my ubuntu 20.04 lts on wsl2 using localhost:3000 using yarn start or even localhost:5000 using yarn build, but for whatever reason, Netlify throws an error during runtime.

6:52:01 PM: ModuleNotFoundError: Module not found: Error: Can't resolve 'electron' in '/opt/build/repo/node_modules/swarm-js/node_modules/got'
6:52:01 PM: > Build error occurred
6:52:01 PM: Error: > Build failed because of webpack errors
6:52:01 PM:     at /opt/build/repo/node_modules/next/dist/build/index.js:15:924
6:52:01 PM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/telemetry/trace/trace.js:6:584)
6:52:01 PM: error Command failed with exit code 1.

Recommend deleting the node modules folder. Build it again. it should resolve the error. It did for me. Hope it works.

  • So, how would that work exactly. If the .gitignore ignores uploading node_modules. Then Netlify would be deploying fresh node_modules every time a deploy is triggered. Oct 13 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.