https://serverless-stack.com/ logo
#help
Title
# help
k

Kevin Grimm

06/04/2022, 4:38 AM
I've been working through an
npx sst build
error with a Next/Tailwind starter blog for 3 nights worth of debugging and currently facing a
TypeError
. I've been testing different packages, package versions, config files etc but haven't figured out how to crack this one yet
Copy code
> Build error occurred
TypeError: Cannot read properties of undefined (reading '1')
    at isFileType (node:fs:208:19)
    at Object.readFileSync (node:fs:456:16)
    at /path/to/files/frontend/.next/serverless/chunks/669.js:101784:19
    at Array.map (<anonymous>)
    at /path/to/files/frontend/.next/serverless/chunks/669.js:101783:30
    at Object.35240 (/path/to/files/frontend/.next/serverless/chunks/669.js:101788:2)
    at __webpack_require__ (/path/to/files/frontend/.next/serverless/webpack-runtime.js:25:43)
    at Object.19625 (/path/to/files/frontend/.next/serverless/chunks/669.js:228937:18)
    at __webpack_require__ (/path/to/files/frontend/.next/serverless/webpack-runtime.js:25:43)
    at Object.90809 (/path/to/files/frontend/.next/serverless/chunks/332.js:229:28) {
  type: 'TypeError'
}
What's odd is that
npm run build
runs in the
frontend
directory; it's just when trying to execute via
sst
where there's an issue... at this point I still can't say for certain that this is an SST issue, but I've scoured multiple threads/questions/issues to no avail. I'm also inexperienced with webpack which is being used in the starter (https://github.com/timlrx/tailwind-nextjs-starter-blog) Worst case scenario I am going to spin up a new Next frontend and incrementally add in pages/components while validating the build works via
npx sst build
. I have a separate SST app that's working with a Next frontend though that one has far fewer bells and whistles (which I'm suspecting is a potential issue besides my lack of familiarity w/ compiling)
I ended up using a less feature-rich template and
npx sst deploy
is working. It remans beyond me what the issue with the former template was, though I suspect it was likely a dependency/package issue.
Also expect this boils down to "I need to learn more about bundling" (@thdxr I know you're a fan of Vite) so start to ramp up here
f

Frank

06/05/2022, 9:24 PM
Hey @Kevin Grimm, the
NextjsSite
construct uses the serverless-nextjs library for bundling.
It bundles the Next.js app the same way as the
sst.NextjsSite
.
Give that construct a try, if it works, it’s probably an SST bug.
k

Kevin Grimm

06/05/2022, 9:32 PM
Cool thanks for this @Frank! I managed to get this deployed and integrated the additional features that weren't throwing any errors. But I'll take a look at this for future reference
There was some MDX bundling going on in the former that I think was the issue. Ended up just using
.md
files
17 Views