0

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
Shivang Patel
  • 157
  • 1
  • 3
  • 13

6 Answers6

2

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

SanSolo
  • 2,267
  • 2
  • 24
  • 32
  • I got an error when running this command. Check my question for more details (I updated it). – Shivang Patel Dec 22 '18 at 13:58
  • @ShivangPatel delete the npm-cache found in this path: `C:\Users\Shivang\AppData\Roaming\npm-cache` and try again. This is definitely cache related issue – SanSolo Dec 22 '18 at 14:04
  • For some reason, I can't delete the folder. I tried right clicking and then clicking delete but that didn't work. I even tried dragging to the recycling bin, but that didn't work either. – Shivang Patel Dec 22 '18 at 14:15
  • @ShivangPatel then may be some virus infection or admin permission issues. Try again after restarting – SanSolo Dec 22 '18 at 14:16
  • I restarted and ran as admin, but it didn't make a difference. I am going to run a virus scanner right now. – Shivang Patel Dec 22 '18 at 14:24
  • I ran Avast and Malware-bytes but they didn't find any viruses. Do you have any other suggestions? – Shivang Patel Dec 22 '18 at 14:43
  • @ShivangPatel sorry nothing else. Your solution involves that npm-cache folder – SanSolo Dec 22 '18 at 14:43
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/185658/discussion-between-shivang-patel-and-sansolo). – Shivang Patel Dec 22 '18 at 18:22
0

Did you try to execute the command as administrator?

Stackedo
  • 803
  • 2
  • 8
  • 19
0

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
Sikandar
  • 160
  • 1
  • 9
0

Try running these commands.

npm cache clean --force

And then

sudo npm install -g create-react-app

This should work.

Thesonter
  • 182
  • 12
0

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

0

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.

choco
  • 96
  • 7