aygin
aygin

Reputation: 89

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

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?

Upvotes: 7

Views: 7225

Answers (5)

Hussein kizz
Hussein kizz

Reputation: 11

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!

Upvotes: 1

Azad Shaikh
Azad Shaikh

Reputation: 1

Change cache folder.

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

Upvotes: 0

Gimnath
Gimnath

Reputation: 1078

You can use,

npx create-react-app yourAppName

Upvotes: -1

eagerprince
eagerprince

Reputation: 123

$ npx create-react-app your project name

Upvotes: -2

kamrankamranifard
kamrankamranifard

Reputation: 618

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

Upvotes: 29

Related Questions