File size: 1,230 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
---
title: Re-exporting all exports from a page is disallowed
---
## Why This Error Occurred
The following export can potentially break Next.js' compilation of pages:
```jsx filename="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:
```jsx filename="pages/example-a.js"
import fs from 'fs'
export default function A() {
return <main />
}
export function getStaticProps() {
fs
return { props: {} }
}
```
```jsx filename="pages/example-b.js"
export * from './example-a'
```
Would cause the following error:
```txt
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:
```jsx filename="pages/example-a.js"
export { default } from './example-b'
```
If the other page uses `getServerSideProps` or `getStaticProps`, you can re-export those individually too:
```jsx filename="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]'
```
|