Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add error link when missing appDir: true #43293

Merged
merged 6 commits into from Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions errors/experimental-app-dir-config.md
@@ -0,0 +1,27 @@
# 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)
4 changes: 4 additions & 0 deletions errors/manifest.json
Expand Up @@ -761,6 +761,10 @@
{
"title": "next-router-not-mounted",
"path": "/errors/next-router-not-mounted.md"
},
{
"title": "experimental-app-dir-config",
"path": "/errors/experimental-app-dir-config.md"
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions packages/next/lib/find-pages-dir.ts
Expand Up @@ -41,12 +41,12 @@ export function findPagesDir(
if (!isAppDirEnabled) {
if (appDir != null && pagesDir == null) {
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) {
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) {
Expand Down
Expand Up @@ -14,7 +14,7 @@ const dir = path.join(__dirname, '..')
const nextConfig = path.join(dir, 'next.config.js')
const pagesIndex = path.join(dir, 'pages', 'index.js')
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>) {
it('should print error when missing config with app', async () => {
Expand Down