trying to get my nextjs site built through SST and...
# help
m
trying to get my nextjs site built through SST and getting an error. I’m thinking it has to do with Web3 + SSR, but I do not get the error if I run
yarn build
in the directory, only when I run sst deploy.
Copy code
ModuleNotFoundError: Module not found: Error: Can't resolve 'electron' in '/Users/matt.smithburger/Projects/mintopoly/server/node_modules/swarm-js/node_modules/got'


> Build error occurred
Error: > Build failed because of webpack errors
    at /Users/matt.smithburger/Projects/mintopoly/server/node_modules/next/dist/build/index.js:397:19
    at async Span.traceAsyncFn (/Users/matt.smithburger/Projects/mintopoly/server/node_modules/next/dist/telemetry/trace/trace.js:60:20)
    at async Object.build [as default] (/Users/matt.smithburger/Projects/mintopoly/server/node_modules/next/dist/build/index.js:77:25)

Error: There was a problem building the "Site" NextjsSite.
    at NextjsSite.buildApp (/Users/matt.smithburger/Projects/mintopoly/server/node_modules/@serverless-stack/resources/src/NextjsSite.ts:545:13)
    at new NextjsSite (/Users/matt.smithburger/Projects/mintopoly/server/node_modules/@serverless-stack/resources/src/NextjsSite.ts:103:16)
    at new UIStack (/Users/matt.smithburger/Projects/mintopoly/server/lib/UI.ts:11:18)
    at Object.main (/Users/matt.smithburger/Projects/mintopoly/server/lib/index.ts:30:3)
    at Object.<anonymous> (/Users/matt.smithburger/Projects/mintopoly/server/.build/run.js:93:16)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:816:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)

There was an error synthesizing your app.
f
Hey @Matthew Smithburger, would it be easy for you to create a minimal Next.js app that can reproduce this error. I can give it a try on my end.
Alternatively, in your
node_modules/nextjs-lambda/dist/build.js
, if you look for
subprocess
, you should see something like this:
Copy code
const subprocess = (0, execa_1.default)(cmd, args, {
    cwd,
    env
});
If you print out
cmd
,
args
,
cwd
, and
env
, that can give us some idea of what command was actually ran in which working directory. And we can try running the command manually in the terminal.
Let me know if that works.
m
@Frank here is the log for the cmd, args, cwd, and env in that order
Copy code
"./node_modules/.bin/next"
[
  "build"
]
"/Users/matt.smithburger/Projects/mintopoly/server/frontend"
{}
also note that it’s a monorepo
tried running
./node_modules/.bin/next build
inside the
frontend
directory and it seems to build
f
hmm.. that’s really weird. Would it be possible to create a minimal repo with the issue?
Here are a few quick steps: • clone this SST repo containing a really dummy Next.js app - https://github.com/serverless-stack/serverless-stack/tree/master/examples/nextjs-app • add a dummy
getStaticProps
in
frontend/pages/index.js
• setup electron and web3 • run
sst build
and see if you can reproduce the issue
Let me know how it goes!