rsnext/errors/promise-in-next-config.md
Tim Neutkens c74e4f21ff
Add support for async fn / promise in next.config.js/.mjs (#33662)
- Add support for async function / promise export in next.config.js/.mjs
- Update docs

Adds support for https://twitter.com/timneutkens/status/1486075973204422665

But also the simpler version:

```js
module.exports = async () => {
  return {
    basePath: '/docs'
  }
}
```



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Documentation added

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-02-07 08:48:35 +00:00

557 B

Promise In Next Config

Why This Error Occurred

The webpack function in next.config.js returned a promise which is not supported in Next.js. For example, below is not supported:

module.exports = {
  webpack: async function (config) {
    return config
  },
}

Possible Ways to Fix It

In Next.js versions above 12.0.10, module.exports = async () => is supported.

For older versions, you can check your next.config.js for async or return Promise.

Potentially a plugin is returning a Promise from the webpack function.