Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to create new app. #4437

Closed
rbiggs opened this issue May 11, 2018 · 17 comments
Closed

Fails to create new app. #4437

rbiggs opened this issue May 11, 2018 · 17 comments

Comments

@rbiggs
Copy link

rbiggs commented May 11, 2018

Is this a bug report?

Yes

Did you try recovering your dependencies?

(Write your answer here.)

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

$: npx create-react-app --info
npx: installed 67 in 5.917s

Environment:
  OS:  macOS High Sierra 10.13.4
  Node:  8.11.1
  Yarn:  1.6.0
  npm:  6.0.0
  Watchman:  Not Found
  Xcode:  Xcode 9.3 Build version 9E145
  Android Studio:  Not Found

ERROR: package.json not found!

Steps to Reproduce

(Write your steps here:)

  1. I installed react-create-app as follows:
npm i -g create-react-app
  1. After installation was complete I tried to create a new React project with:
react-create-app my-app
  1. This fails with the following error:
$: create-react-app my-app

Creating a new React app in /Users/rbiggs/Desktop/my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: spawn yarnpkg ENOENT
    at _errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Expected Behavior

(Write what you thought would happen.)

Actual Behavior

When I create a new React app, it creates the folder and a partial package.json file as illustrated below:

{
  "name": "my-app",
  "version": "0.1.0",
  "private": true
}

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

@farhanaslam5151
Copy link

farhanaslam5151 commented May 12, 2018

In step 2 you are creating project please write this command
Create-react-app my-app
Hope it will work fine.

@rbiggs
Copy link
Author

rbiggs commented May 12, 2018

My bad. I was in fact running create-react-app my-app, which does not work. Here's the console error:

$: create-react-app my-app

Creating a new React app in /Users/rbiggs/Desktop/my-app.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: spawn yarnpkg ENOENT
    at _errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

@farhanaslam5151
Copy link

Try upgrading node, then npm uninstall - g create-react-app and then use npx like
Npx create-react-app my-app

@farhanaslam5151
Copy link

If still not working then try this
npx -p create-react-app -c 'create-react-app myapp'
Hope it will work for you.

@rbiggs
Copy link
Author

rbiggs commented May 13, 2018

I tried that and got this:

$: npx -p create-react-app -c 'create-react-app myapp'
npx: installed 67 in 6.087s

Creating a new React app in /Users/rbiggs/Desktop/myapp.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: spawn yarnpkg ENOENT
    at _errnoException (util.js:1022:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:190:19)
    at onErrorNT (internal/child_process.js:372:16)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

@bondz
Copy link
Contributor

bondz commented May 13, 2018

Try npx -p create-react-app -c 'create-react-app myapp --use-npm'

@rbiggs
Copy link
Author

rbiggs commented May 13, 2018

Surprisingly, that did work. But why? Something is definitely not right if the documented command is not working and this convoluted approach does.

@iansu
Copy link
Contributor

iansu commented May 13, 2018

It looks like your yarn installation is broken in some way. If you have yarn installed it will be used by default, which is what happened with the first command. The second command explicitly uses npm instead of yarn.

@rbiggs
Copy link
Author

rbiggs commented May 13, 2018

So, how do you install create-react-app with yarn? The README doesn't even have anything about how to install it. I looked at it on npm, didn't have any install instructions so I assumed I was supposed to do a normal npm i -g create-react-app to install it. You need to update the README with install instructions.

@iansu
Copy link
Contributor

iansu commented May 14, 2018

Yarn is automatically used if it's present on your system. So the first set of commands you tried as well as npx create-react-app my-app both used yarn. The command that did work for you used npm because of the --use-npm flag which is documented.

@rbiggs
Copy link
Author

rbiggs commented May 14, 2018

I do not find --use-npm anywhere in the documentation--README or user guide.

@iansu
Copy link
Contributor

iansu commented May 14, 2018

My bad. I thought it was in the user guide. It is in the help for the create-react-app command: create-react-app --help. I guess that's what I was thinking of. Feel free to send a PR if you'd like to add it to the user guide.

@rbiggs
Copy link
Author

rbiggs commented May 15, 2018

I don't think I'm the person to try to explain this. It was a bit over my head and convoluted.

@Timer
Copy link
Contributor

Timer commented May 24, 2018

Closing this as it seems resolved, but a re-install or an upgrade of your Yarn installation should fix this for the future (or uninstall it if you don't use it).

@Timer Timer closed this as completed May 24, 2018
@rbiggs
Copy link
Author

rbiggs commented May 24, 2018

Why is this a Yarn only package? That wasn't clear in the documentation, and it is available on NPM to install. Yet you need Yarn for it to work? I'd prefer a normal npm package like everything else I use. If it doesn't work with NPM, then you should take it off NPM so no confusion. Is there an alternative to this that doesn't require Yarn???

@Timer
Copy link
Contributor

Timer commented May 25, 2018

This is not a Yarn only package. If you remove Yarn from your system, npm will be used by default.

If you want to keep Yarn installed on your system but not update it, you'll have to use a special command as posted above: npx -p create-react-app -c 'create-react-app myapp --use-npm'.

@rbiggs
Copy link
Author

rbiggs commented May 25, 2018

Thanks for the update. Actually, I never had Yarn installed on my system. But it didn't work with just NPM.

@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants