7

when I use regular npm or npx commands like

npm -version

or

npx -version

there is no error, but for my react native project when I use

npx react-native init testApp

it shows this error:

does not contain a package.json file in appdata folder

How can I fix this error?

aygin
  • 109
  • 1
  • 7

5 Answers5

29

this error occurs usually when name of the PC contain a space. like

mycomputer name

you should fix this by redefine your npm cache root try:

npm config set cache "C:\Users\mycomputer~1name\AppData\Roaming\npm-cache" --global

be careful for space character in the pc name you should use "~1" instead

good luck

  • 2
    It as created another directory `mycomputer~1name` under `C:\Users` along with `mycomputer name` – Zaheer Mar 17 '20 at 13:59
1

This is because of the space in your computer's name, and besides working around your computer's namespace, you can also try installing the create-react-app globally as npm i -g create-react-app and then run your npx create-react-app your-app-name command again, this solved it for me!

  • Hello and welcome to SO! Please read the [tour](https://stackoverflow.com/tour), and [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) – Tomer Shetah Dec 20 '20 at 11:10
0

Change cache folder.

npm config set cache C:\tmp\nodejs\npm-cache --global
-1

You can use,

npx create-react-app yourAppName
Gimnath
  • 824
  • 9
  • 11
-2
$ npx create-react-app your project name
Pingolin
  • 3,161
  • 6
  • 25
  • 40
eagerprince
  • 115
  • 1
  • 5