"command not found: create-next-app" how do I create a next application?

Viewed 26557

I am new to Next.js I am using this command to create my app:

npx create-next-app

but it is giving an error which is:

Error: EPERM: operation not permitted, mkdir 'C:\Users\danyyal' command not found: create-next-app

how to create the app? p.s I have nodejs installed.

9 Answers

First install create-next-app globally by doing

npm i -g create-next-app

After you can use create-next-app CLI to create next app.

If you want to create new next app in current directory do

create-next-app .

For a named next app just do

create-next-app your-app-name

Before create it manuely with

npm install react next react-router

Try to install the create-next-app package

npm i create-next-app

Then you can do again:

npx create-next-app my-awesome-app

You can always setup the project manually.

Step 1 : Install next, react and react-dom in your project:

npm install next react react-dom

Step 2 : Open package.json and add the following scripts:

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

Step 3: Populate ./pages/index.js with the following contents:

function HomePage() {
  return <div>Welcome to Next.js!</div>
}

export default HomePage

To start developing your application run npm run dev or yarn dev. This starts the development server on http://localhost:3000.

UPDATE

Since you needed more help.

Create a new folder and name it as you like,then open your terminal & go into the project folder and run the step 1 commands. Now open package.json file and inside that write the step 2 code. Now create pages folder inside the current project directory and inside that create a index.js file and write the step 3 code. Now run the project by doing npm run dev. So the project structure will be like this.

--Nextjs Project
     ---pages
           |--- index.js
     ---packages.json

Try running npm i create-next-app first.

You can create it manually by creating a folder and run npm init to create a package.json file the run npm install next react react-dom --save, Open the package.json and add this

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

You must use node 10.13 or later to make it work !

NextJS Requirements

1. nvm use 10

2. npx create-next-app

Try installing it globally first, using the command npm install -g create-react-app

And then, you can create your app using the command, npx create-react-app

First, install npx globally (if not)

npm i -g npx

Then, run command create-next-app

npm i create-next-app

then you will be able to create-next-app by running

npx create-next-app appname

first installed npx globally using -g npx i -g npx

then installed npm i -g create-next-app

Related