[Solved] Next is not recognized as an internal or external command, operable program or batch file

Next JS Mohaimen Khalid

Problem:

I have tried to install next js app using "yarn create next-app my-app".  Then got the error -

 next is not recognized as an internal or external command, operable program or batch file
Solution 1:

Here is the first solution to this problem. follow the steps: If you are using npx then run these commands -

npx create-next-app project-name
cd project-name
npm run dev
If you are using yarn then run this commands -
yarn create-next-app project-name
cd project-name
yarn run dev
Solution 2:

Have you tried the first solution? If the first solution is not working for you then try this solution:

Hopefully, It will work for you.

Just follow the steps - 

  1. First, open your terminal
  2. Then go to your project directory using "cd your project_name"
  3. Finally copy the following command
npm install next react react-dom
# or
yarn add next react react-dom

Open project's  package.json and add to your file the following scripts:

"scripts": {
  "dev": "next dev",
  "build": "next build",
  "start": "next start"
}

Thank you for reading the article. If you face any problems, please comment below.