最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - create-react-app aborting with code ENOENT - Stack Overflow

programmeradmin0浏览0评论

Just started out with React using an online course from Udemy. For some reason my create-react-app stopped working all of a sudden and it shows this log.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\postcss-normalize
npm ERR! dest C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\.postcss-normalize.DELETE
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\postcss-normalize' -> 'C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\.postcss-normalize.DELETE'
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:
npm ERR!     C:\Users\Vahram\AppData\Roaming\npm-cache\_logs\2021-05-06T21_38_53_463Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting pokedex-exercise/ from C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5
Done.

Just started out with React using an online course from Udemy. For some reason my create-react-app stopped working all of a sudden and it shows this log.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\postcss-normalize
npm ERR! dest C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\.postcss-normalize.DELETE
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\postcss-normalize' -> 'C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5\pokedex-exercise\node_modules\.postcss-normalize.DELETE'
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:
npm ERR!     C:\Users\Vahram\AppData\Roaming\npm-cache\_logs\2021-05-06T21_38_53_463Z-debug.log

Aborting installation.
  npm install --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.

Deleting generated file... node_modules
Deleting generated file... package.json
Deleting pokedex-exercise/ from C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5
Done.

I checked out similar questions on here and there were some solutions I tried. The usual answer is to delete package.json but I don't have that seeing as I'm trying to make a new React app. Here's what I've tried so far:

  1. Originally tried npx create-react-app my_app
  2. Then tried running npm install -g create-react-app and then create-react-app my_app.
  3. Then tried npm cache clean --force followed by npm rebuild then step 2 again.
  4. Then tried npm init --yes to generate a package.json file, followed by trying to make a new app again using CRA.
  5. Tried restarting the machine

Curious thing I noticed that I'm not sure is related to the issue: When I go to Task Manager, there are two Node.js processes running. When I try to end one, it spawns another Node.js process... I can't get rid of all Node.js processes. This is why I originally restarted the machine.

Any help is appreciated! I have no idea how to proceed... I'm even thinking of formatting my machine and starting everything from scratch. However, I'd like to know why this happens so that I can avoid it in the future.

Share Improve this question edited May 7, 2021 at 5:12 Vahram Poghosyan asked May 6, 2021 at 21:48 Vahram PoghosyanVahram Poghosyan 531 silver badge5 bronze badges 10
  • The error ENOENT: no such file or directory, rename is telling you that either the rename command is not anything that your OS knows about (but it comes with Windows so that should work) or the path given to rename doesn't exist, so: is this on a genuinely create attempt? – Mike 'Pomax' Kamermans Commented May 7, 2021 at 5:01
  • @Mike'Pomax'Kamermans Yeah, the command should be recognized (the whole thing was working just a day ago). Sorry, I don't understand the second part of your comment. I think you're asking if I'm running create-react-app with no prior configurations or anything like that? If so, yes. I'm just cding into the directory C:\Users\Vahram\Desktop\Udemy-React\Personal-Notes\Sec5 and running either npx create-react-app pokedex-exercise or create-react-app pokedex-exercise. – Vahram Poghosyan Commented May 7, 2021 at 5:06
  • @Kamermans no that's not what it says, it says that the rename operation failed with error ENOENT. – CherryDT Commented May 7, 2021 at 5:45
  • In my experience you get this issue when you have some other process watching the directory - for example VSCode. What is the command line of the node process that you see in task manager? (enable the command line column in the details grid to find out) – CherryDT Commented May 7, 2021 at 5:47
  • 1 @ale917k Just made a new desktop folder, cded into it, and tried a whole new name for an app I haven't tried before. It worked... So thank for that answer! But what's going on? There are no projects showing up in the file explorer in the folders I was trying to create it in before. – Vahram Poghosyan Commented May 7, 2021 at 6:18
 |  Show 5 more comments

4 Answers 4

Reset to default 16

I just solved this using the following command.

npm uninstall -g create-react-app

and then:

npm install -g create-react-app

Regards

While I may be a bit late to the conversation, I'd like to offer some guidance that could prove helpful, especially for newcomers. I've encountered a particular issue with the new create-react-app, and here's a solution to address it:

Step 1: Start by uninstalling the global create-react-app package using the command npm uninstall -g create-react-app.

Step 2: Next, reinstall the create-react-app globally by executing npm install -g create-react-app.

Step 3: Don't forget to close the Terminal window.

Step 4: Finally, initiate the creation of your new React application with the command npx create-react-app my-app.

These steps should assist you in resolving the issue you're facing.

You can try reinstalling npx using npm i -g npx

only npm uninstall -g create-react-app and then, installer anyway version.

发布评论

评论列表(0)

  1. 暂无评论