0

node version v14.15.0 npm version 6.14.8

This is the Error

$ npx react-native init Sjp
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Ri\AppData\Roaming\npm-cache\_npx\19852" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Mi HI Ri\AppData\Roaming\npm-cache\_logs\2020-11-26T07_12_41_451Z-debug.log
Install for [ 'react-native@latest' ] failed with code 1
Mr.
  • 9,429
  • 13
  • 58
  • 82

2 Answers2

0

This error is occurring because of the spaces in your username (Mi HI Ri) and you can resolve it by doing the following steps (on Windows):

  1. Open CMD as administrator then go to C:\Users folder and enter command:
dir /x
  1. You will now see a list of items and one of the rows will be having the username (Mi HI Ri). Copy down the text on its left which will be something like MiHIRi~1 (can be different so please don't copy it from here).
  2. And then update your path by executing the command:
// Replace MiHIRi~1 below with the text copied earlier
npm config set cache "C:\Users\MiHIRi~1\AppData\Roaming\npm-cache" --global
usafder
  • 791
  • 5
  • 17
0

I have faced the same issue, do nothing just a quick fix.

first, run the command npm i react-native@latest -g then create your project with your command i.e npx react-native init Sjp