npx create-next-app@latest is giving errors
Asked Answered
B

9

5

I am trying to create a new nextjs app but I get a npm ERR! ENOTEMPTY: directory not empty error. Please the image below the screenshot of the errors

Its been working fine for the past year I am not sure what really happened.

Please help me out I couldnt find any answers on Google.

node version
v19.8.1
npm version
9.5.1
React version
18.2.0
Next version
13.2.4
OS version
Ubuntu 22.04
Banas answered 17/3, 2023 at 19:40 Comment(3)
try doing npx create-next-app@latest <project-name>Chare
gives the same errorsBanas
You are not using the stable version of Node. Switch to 18.15.0 and start over.Lacedaemonian
U
7

You should try this first

npm init 
npm install create-next-app@latest --save
npm create-next-app <appname>

If it's not work you might use stable version of node like 18.15.0
If you don't know how to switch node version this will help you
https://github.com/nvm-sh/nvm

And try your step
hope it's work!

Undertint answered 18/3, 2023 at 11:27 Comment(0)
E
13

The reason why it doesn't work is because you don't have an npm directory in your AppData\Roaming.

Create C:\Users\(You)\AppData\Roaming\npm to make npx create-next-app@latest work normally.

Englacial answered 4/11, 2023 at 10:17 Comment(1)
this should be labeled as correct answerPostobit
U
7

You should try this first

npm init 
npm install create-next-app@latest --save
npm create-next-app <appname>

If it's not work you might use stable version of node like 18.15.0
If you don't know how to switch node version this will help you
https://github.com/nvm-sh/nvm

And try your step
hope it's work!

Undertint answered 18/3, 2023 at 11:27 Comment(0)
C
3

I had the same issues, I tried several things it didn't work. What work was there is no npm folder in AppData/Roaming/ so I created

npm folder in Roaming

.../AppData/Roaming/npm

and it works

Coquelicot answered 21/12, 2023 at 6:59 Comment(2)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Pizzeria
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewTifanytiff
B
2

Upgrade the Node Package Manager (npm) to the latest version; you can use the following command:

npm install -g npm

This command installs the latest version of npm globally on your system. The -g flag ensures that npm is installed globally, allowing you to use the updated npm across all your projects.

After running this command, you can verify the installation and check the updated version by using:

npm -v

This should display the new version number, confirming that npm has been successfully upgraded.

Make sure you have the necessary permissions to install global packages, and if you encounter any issues, consider using a package manager like sudo on Unix-based systems or running your terminal as an administrator on Windows.

Keep in mind that updating npm may also require updating Node.js itself, so it's a good practice to check for the latest Node.js version and update it if needed. You can find the latest version on the official Node.js website: https://nodejs.org/

Biblical answered 7/12, 2023 at 10:38 Comment(0)
A
1

I had the same issue, for some reason no NPM folder was created in

C:\Users<Username>\AppData\Roaming

so i just created that folder then it worked out

Agile answered 17/11, 2023 at 22:42 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Pizzeria
B
0

My problem was not exactly the same, I got the error ETIMEDOUT instead of ENOTEMPTY, however @Bear's answer led me to the solution and the cause of the error.

I had the version 18.8 of NodeJS, but create-next-app@latest needed >=18.17.0, the message was very clear when doing npm i create-next-app@latest while there was just a timeout error when doing npx --verbose create-next-app@latest.

The fact is that because my version of node did not match latest requirements, it did not find a compatible version of that package on npm.

I just had to install a newer version of NodeJS to fix the error.

Bibliology answered 1/11, 2023 at 20:44 Comment(0)
K
0

I was able to solve this by updating nvm with this

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

Source: https://github.com/nvm-sh/nvm?tab=readme-ov-file

And then updating node js with the following 3 steps:

npm install -g n

n lts

nvm install node

Source: https://www.freecodecamp.org/news/how-to-update-node-and-npm-to-the-latest-version/

Then I was able to install next with:

npx create-next-app --example https://github.com/vercel/platforms platforms

Hope it helps someone.

Kippie answered 23/7 at 3:17 Comment(0)
B
0

This worked for me audit fix --force

Bonhomie answered 24/7 at 13:2 Comment(0)
D
0

In my case, it was solved by just running the following command.

npm install create-next-app@latest --save

And then, "npx create-next-app@latest" started working.

Dominus answered 1/11 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.