npx react-native init error does not contain a package.json file in appdata folder
Asked Answered
O

5

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?

Ogpu answered 19/12, 2019 at 7:36 Comment(0)
A
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

Ardel answered 19/12, 2019 at 7:44 Comment(1)
It as created another directory mycomputer~1name under C:\Users along with mycomputer nameBuchner
B
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!

Burley answered 20/12, 2020 at 10:39 Comment(1)
Hello and welcome to SO! Please read the tour, and How do I write a good answer?Arbiter
P
0

Change cache folder.

npm config set cache C:\tmp\nodejs\npm-cache --global
Photofinishing answered 7/8, 2020 at 13:22 Comment(0)
B
-1

You can use,

npx create-react-app yourAppName
Bergquist answered 19/12, 2019 at 8:55 Comment(1)
It creates React JS project instead of React Native projectBuchner
F
-2
$ npx create-react-app your project name
Fast answered 19/12, 2019 at 7:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.