Unverified Commit aa51c26c authored by Balázs Orbán's avatar Balázs Orbán Committed by GitHub

docs: add error link when missing `appDir: true` (#43293)

[Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1669206360940399)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ]
[e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
Co-authored-by: 's avatarJiachi Liu <inbox@huozhi.im>
parent 685c87c9
# Experimental `appDir: true`
#### Why This Error Occurred
Your project contains a directory named `app/`. Since Next.js 13, this is a [reserved name](https://nextjs.org/blog/next-13#new-app-directory-beta).
#### Possible Ways to Fix It
To use the new app directory and its features, please add `appDir: true` to your configuration in `next.config.js` under `experimental`.
```js
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}
module.exports = nextConfig
```
If you do not want to use the new `app/` directory features yet, but have a directory named `app/`, rename the directory to something else.
### Useful Links
- [Next.js 13 App directory (Beta)](https://nextjs.org/blog/next-13#new-app-directory-beta)
- [App directory (Beta) documentation](https://beta.nextjs.org/docs)
...@@ -761,6 +761,10 @@ ...@@ -761,6 +761,10 @@
{ {
"title": "next-router-not-mounted", "title": "next-router-not-mounted",
"path": "/errors/next-router-not-mounted.md" "path": "/errors/next-router-not-mounted.md"
},
{
"title": "experimental-app-dir-config",
"path": "/errors/experimental-app-dir-config.md"
} }
] ]
} }
......
...@@ -41,12 +41,12 @@ export function findPagesDir( ...@@ -41,12 +41,12 @@ export function findPagesDir(
if (!isAppDirEnabled) { if (!isAppDirEnabled) {
if (appDir != null && pagesDir == null) { if (appDir != null && pagesDir == null) {
throw new Error( throw new Error(
'> The `app` dir is experimental. Please add `{experimental:{appDir: true}}` to your `next.config.js` to enable it' '> The `app` directory is experimental. To enable, add `appDir: true` to your `next.config.js` configuration under `experimental`. See https://nextjs.org/docs/messages/experimental-app-dir-config'
) )
} }
if (appDir != null && pagesDir != null) { if (appDir != null && pagesDir != null) {
Log.warn( Log.warn(
'The `app` dir is experimental. Please add `{experimental:{appDir: true}}` to your `next.config.js` to enable it' 'The `app` directory is experimental. To enable, add `appDir: true` to your `next.config.js` configuration under `experimental`. See https://nextjs.org/docs/messages/experimental-app-dir-config'
) )
} }
if (pagesDir == null) { if (pagesDir == null) {
......
...@@ -14,7 +14,7 @@ const dir = path.join(__dirname, '..') ...@@ -14,7 +14,7 @@ const dir = path.join(__dirname, '..')
const nextConfig = path.join(dir, 'next.config.js') const nextConfig = path.join(dir, 'next.config.js')
const pagesIndex = path.join(dir, 'pages', 'index.js') const pagesIndex = path.join(dir, 'pages', 'index.js')
const msg = const msg =
'The `app` dir is experimental. Please add `{experimental:{appDir: true}}` to your `next.config.js` to enable it' 'The `app` directory is experimental. To enable, add `appDir: true` to your `next.config.js` configuration under `experimental`. See https://nextjs.org/docs/messages/experimental-app-dir-config'
function runTests(justPutIt: () => Promise<string>) { function runTests(justPutIt: () => Promise<string>) {
it('should print error when missing config with app', async () => { it('should print error when missing config with app', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment