Skip to content
DocsErrorsRe-exporting all exports from a page is disallowed

Re-exporting all exports from a page is disallowed

Why This Error Occurred

The following export can potentially break Next.js' compilation of pages:

pages/example.js
export * from '...'

This is because Node.js code may be leaked to the browser build, causing an error. For example, the following two pages:

pages/example-a.js
import fs from 'fs'
 
export default function A() {
  return <main />
}
 
export function getStaticProps() {
  fs
  return { props: {} }
}
pages/example-b.js
export * from './example-a'

Would cause the following error:

Module not found: Can't resolve 'fs' in './pages/example-b.js'

Possible Ways to Fix It

Update your page to re-export the default component only:

pages/example-a.js
export { default } from './example-b'

If the other page uses getServerSideProps or getStaticProps, you can re-export those individually too:

pages/example-a.js
export { default, getServerSideProps } from './example-b'
// or
export { default, getStaticProps } from './example-b'
// or
export { default, getStaticProps, getStaticPaths } from './example-b/[dynamic]'