#Monorepo shared ui throwing module not found on pnpm build

2 messages · Page 1 of 1 (latest)

tawny granite
#

I have a monorepo with the following folder structure represented in json:

"apps": ["admin", "web"],
"packages": ["shared-ui"]

shared-ui is a next.js app that has index.ts in the root exporting all of it's components

// shared-ui
//   index.ts
//   next-config.js
//   app
//     ...this folder is empty since I am only using shared-ui to export components

// imports global styles that should be applied to all shared-ui components
import "./src/styles/globals.css" 

// exports all components that should be used in apps
export { default as Header } from "~/components/common/header/header"
export { default as Footer } from "~/components/common/footer/footer"

I can then import these in my apps like this:

import { Header } from "@repo/shared-ui"
import { Footer } from "@repo/shared-ui"

this works well in dev and I can see the components and their styles applied from "globals.css", but when I run pnpm --filter admin run build it gives me the following error:

Import trace for requested module:
./src/app/preview/page.tsx

../../packages/shared-ui/index.ts
Module not found: Can't resolve '~/components/common/header/header'

Any ideas?

thorn zincBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)