0

I have a problem with creating a new react native project, When I run

react-native init AwesomeApp

all I get is only (package.json and yarn-error.log) there is no iOS or Android folders in the command

This will walk you through creating a new React Native project in /Users/man/AwesomeApp
Using yarn v1.16.0
Installing react-native...
yarn add v1.16.0
error An unexpected error occurred: "/Users/man/package.json: Unexpected end of JSON input".
info If you think this is a bug, please open a bug report with the information provided in "/Users/man/AwesomeApp/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Error: Command failed: yarn add react-native --exact
    at checkExecSyncError (child_process.js:616:11)
    at execSync (child_process.js:652:15)
    at run (/usr/local/lib/node_modules/react-native-cli/index.js:294:5)
    at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3)
    at init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-cli/index.js:153:7)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 70691,
  stdout: null,
  stderr: null
}
Command `yarn add react-native --exact` failed.

My stack is:

  • node: v12.5.0
  • npm: 6.10.0
  • yarn: 1.16.0
  • react-native-cli: 2.0.1
  • react-native: n/a – not inside a React Native project directory
MSH
  • 1

2 Answers2

2

You have a package.json in your home folder. This package.json appears to be invalid.

I suggest you remove it, it most likely should not be there anyway.

Yarn is for whatever reason also looking at parent package.json files.

(Additionally, it is suggested you not install react-native but use npx instead.)

user219095
  • 65,551
0

npm install -g react-native-cli npm install

This command are installed you iOS and Android file or node module

Shivo'ham
  • 101