Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

heshamHanafi's avatar

laravel 9.19 install error

i have error when i try to clone project laravel 9.19 , the error when i run npm run dev it give me error

'next' is not recognized as an internal or external command,
operable program or batch file.

i fix it with install next package, but when i run npm run dev again it give me onther error

Error: > 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
    at Object.findPagesDir (D:\laragon\www\Travel\node_modules\next\dist\lib\find-pages-dir.js:80:19)
    at DevServer.getRoutes (D:\laragon\www\Travel\node_modules\next\dist\server\dev\next-dev-server.js:138:59)
    at new Server (D:\laragon\www\Travel\node_modules\next\dist\server\base-server.js:108:47)
    at new NextNodeServer (D:\laragon\www\Travel\node_modules\next\dist\server\next-server.js:70:9)
    at new DevServer (D:\laragon\www\Travel\node_modules\next\dist\server\dev\next-dev-server.js:97:9)
    at NextServer.createServer (D:\laragon\www\Travel\node_modules\next\dist\server\next.js:144:20)
    at D:\laragon\www\Travel\node_modules\next\dist\server\next.js:159:42
    at async NextServer.prepare (D:\laragon\www\Travel\node_modules\next\dist\server\next.js:134:24)
    at async D:\laragon\www\Travel\node_modules\next\dist\cli\next-dev.js:585:17

I tired to find solution of this error i hope to fine someone fix it .

node version v18.8.0 npm version 8.18.0

0 likes
2 replies
LaryAI's avatar
Level 58

It seems like you are trying to run a Laravel project with Next.js installed. Next.js is a React framework and is not required for Laravel projects.

To fix the error, you can remove Next.js from your project by deleting the node_modules folder and the package-lock.json file. Then, run npm install to reinstall the required packages for your Laravel project.

If you still want to use Next.js in your project, you need to configure it properly. The error message suggests adding appDir: true to your next.config.js file under experimental. Here's an example configuration:

// next.config.js

module.exports = {
  experimental: {
    appDir: true,
  },
};

Make sure to also install the required packages for Next.js by running npm install next react react-dom.

After configuring Next.js, you can run npm run dev to start the development server.

Please or to participate in this conversation.