npm shows an error 'ENOENT: no such file or directory' when creating a react project
Asked Answered
F

3

7

I've installed Node.js for Windows and I'm trying to create a new React project via npm. Upon typing 'npx create-react-app projectName', I receive the following error:

ENOENT: no such file or directory, lstat 'C:\Users\Username\AppData\Roaming\npm'

Does anyone know how to fix this error?

Feline answered 7/7, 2023 at 9:28 Comment(3)
Did you install the npm? Use npm -v to checkNeufer
Yes, I have installed the node.js and checked using npm -vFeline
This should finally be fixed in an upcoming npm release. github.com/npm/cli/issues/7089 When that happens, we can finally write add a new answer to this question :)Hinshelwood
B
15

I got the exact same error with npx nuxi@latest init my-app and the solution was surprisingly simple. Just create that missing directory.

mkdir "%AppData%\npm"
Borges answered 30/8, 2023 at 4:56 Comment(1)
mkdir "%AppData\Roaming\npm%" worked for me (windows 10)Cedric
P
4

I got the exact same error in my Next.js project. The following command worked:

npm install npm -g

Later on I got a similar error in my project so I re-built the project:

npm run build
Pretypify answered 28/10, 2023 at 6:22 Comment(1)
Fixed this for me today, thank you. For those wondering the -g flag installs it "globally" on your machine, you likely only have it installed for your current user before running this command.Dwelling
P
0

To fix this error, let's create a new folder.

First, find this location on your computer:

'C:\Users\Username\AppData\Roaming'.

You might need to replace 'Username' with your actual username.

Once you're there, look for a folder called 'npm'. If you can't find it, don't worry - just create a new, empty folder and name it 'npm'.

That's it! Now, try running your command again.

Pru answered 31/8, 2024 at 19:2 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.