'Error installing create-react-app with npm

When I try to install create-react-app (or nodemon) globally or even within a project, I get the following error. However, I can install other packages perfectly fine both globally and locally. I think it has something to do with the fact that both create-react-app and nodemon are run from the terminal rather than used within a project's code.

I have already tried reinstalling nodejs and opening the terminal as administrator, but that did not work.

$ npm i -D nodemon
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall open
npm ERR! UNKNOWN: unknown error, open 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78\49\9aac8fdb9b898c6d95e47da44f0425e95568d85f83d82f7bae06293b0a03'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_29_35_317Z-debug.log

UPDATE: When I ran npm cache clean --force, I got the following error

$ npm cache clean --force
npm WARN using --force I sure hope you know what you are doing.
npm ERR! path C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78
npm ERR! code UNKNOWN
npm ERR! errno -4094
npm ERR! syscall unlink
npm ERR! UNKNOWN: unknown error, unlink 'C:\Users\Shivang\AppData\Roaming\npm-cache\_cacache\index-v5\78'

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Shivang\AppData\Roaming\npm-cache\_logs\2018-12-22T13_55_42_508Z-debug.log


Solution 1:[1]

Run npm cache clean --force and then try installing again

Solution 2:[2]

Did you try to execute the command as administrator?

Solution 3:[3]

I was facing the same issue. Found a solution for the same.

  • Go to C:\Users\%UserName%\AppData\Roaming\npm-cache
  • Delete all items present there
  • Some files inside 1 or more folders you may not be able to delete, then just rename them to some random name.
  • Now retry npm install. It should work

Solution 4:[4]

Try running these commands.

npm cache clean --force

And then

sudo npm install -g create-react-app

This should work.

Solution 5:[5]

Use npx command instead of npm

Like this, First Mkdir appName mkdir appName Secondly Cd into the app cd appName

Thirdly run npx npx create-react-app ./

This how to run npx in react 18

Solution 6:[6]

Lol i just took the two previous answers and put them together. So the solution is:

npm cache clean --force (-g if first try doesnt work after npx). then just use npx instead of npm.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SanSolo
Solution 2 Stackedo
Solution 3 Sikandar
Solution 4 Thesonter
Solution 5 Tech Voltage
Solution 6 choco