0

I am trying to start writing React code on my new PC. I have installed npm, but when I run npx create-react-app, I am getting the following error:

$ npx create-react-app code-app
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\USER\AppData\Roaming\npm
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\USER\AppData\Roaming\npm'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: C:\Users\USER\AppData\Local\npm-cache\_logs\2023-08-30T08_16_10_555Z-debug-0.log

I have tried to use git bash, VS Code terminal, Windows cmd to run it but still not coming up.

André
  • 1,602
  • 2
  • 12
  • 26
  • Start by clearing the npm cache; `npm cache clean --force` or try to update your npm package globally `npm install -g npm` – Abdel Aug 30 '23 at 08:38
  • Maybe post the log file? Or a snippet of it relating to the error. – 5px Aug 31 '23 at 08:50

2 Answers2

2

This can happen for a multitude of reasons. My guess is that a folder where npm was installed in your computer was moved to a different folder or removed.
Try to reinstall npm with the command npm install -g npm.
If it fails you can follow this guide:
https://stackoverflow.com/a/20711410/13970434

André
  • 1,602
  • 2
  • 12
  • 26
1

This may happen by several reasons like any issues in the directory of node or it may even happen if you are using any proxy or having any network connectivity issues, So try to switch your connection first. If it is not helping then try clearing cache:

npm cache clean --force

Then try to update npm

npm install -g npm
abcd
  • 26
  • 2