DEV Community

Caleb Frieze
Caleb Frieze

Posted on

TurboRepo Next.js Build Error

I was converting an existing NextJs app into a repo that is managed by TurboRepo to give the ability to add more apps to our frontend system. Everything went great and was super smooth until I tried actually running the build scripts. I copied the configuration settings exactly from the docs and a couple sample repos that I found, yet still I had a unique problem.
Here is a snippet of the error:

app:build: - info Creating an optimized production build...
app:build: - info Compiled successfully
app:build: - info Collecting page data...
app:build: TypeError: Cannot read properties of undefined (reading 'P')
Enter fullscreen mode Exit fullscreen mode

I followed the stack trace and noticed that it was trying to do a webpack import of a component that I created in a UI package. That should be fine, however upon further investigation, I hadn't realized I exported the story from Storybooks. At this time, I don't really have a need to explicitly export stories from ui into any other project, so I just removed it. That seemed to fix the error. Now webpack builds NextJs just fine, and the app functions the same as it did before I made it a monorepo.

Hopefully this helps someone else!

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)