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

README uses npm commands, but the tool suggests to use yarn #1497

Closed
benjaminapetersen opened this issue Feb 7, 2017 · 14 comments
Closed

README uses npm commands, but the tool suggests to use yarn #1497

benjaminapetersen opened this issue Feb 7, 2017 · 14 comments

Comments

@benjaminapetersen
Copy link

This is the first time I've used create-react-app, which was pretty smooth and gave me the following message on the cli:

Success! Created react-prod-list at /Development/react-prod-list/
Inside that directory, you can run several commands:

  yarnpkg start
    Starts the development server.

  yarnpkg run build
    Bundles the app into static files for production.

  yarnpkg test
    Starts the test runner.

  yarnpkg run eject
    Removes this tool and copies build dependencies, configuration files
    and scripts into the app directory. If you do this, you can’t go back!

We suggest that you begin by typing:

  cd react-prod-list
  yarnpkg start

Happy hacking!

However, when you browse the README.md file, all references are for npm, such as npm start, npm test, etc.

@ro-savage
Copy link
Contributor

I believe this is because you have yarn installed globally.

If you do not have yarn installed it would tell you to use npm start etc.

@benjaminapetersen
Copy link
Author

Yup. I added yarn per suggestion from react docs site (I've historically used npm, prob like most). Its a bit unsettling when you first install & then get conflicting information, I'm guessing the README.md file just needs a block for both npm & yarn to ensure new users that its not stale content.

@gaearon
Copy link
Contributor

gaearon commented Feb 8, 2017

There is no difference between how those commands work. The intention was that Yarn users probably know what they're doing (Yarn still being a very new project), and should be familiar with npm anyway (since every library out there has instructions for npm and you can't avoid learning it). Maybe that was a wrong assumption?

@gaearon gaearon changed the title README.md file needs some updates! README uses npm commands, but the tool suggests to use yarn Feb 8, 2017
@gaearon
Copy link
Contributor

gaearon commented Feb 8, 2017

By the way it's a bit unfortunate we're suggesting to run yarnpkg start and similar when yarn start would work for most users. I know why we did that (to avoid conflicts with Yarn Java package) but can we somehow be smarter about yarn detection? cc @fson

@fson
Copy link
Contributor

fson commented Feb 8, 2017

I think by default we should show yarn commands in the instructions and not yarnpkg. That was my intent when making the change to internally use yarnpkg anyway, but looks like the instructions also got affected by the change.

This is less than ideal for the minority of users who have both Yarn and that YARN Java package installed. We could assume that they'll find out how to use the yarnpkg alias on their own (since that's what they need to do to use yarn in the first place) or else we'd need to add more complicated Yarn detection.

@Timer
Copy link
Contributor

Timer commented Feb 8, 2017

We could compare command -v yarn and command -v yarnpkg and check if they're equal.

@fson
Copy link
Contributor

fson commented Feb 8, 2017

@Timer That's an interesting idea! They output will be different however, on my system they return /usr/local/bin/yarn and /usr/local/bin/yarnpkg, respectively. And our solution also needs to work on Windows.

That gave me an idea though: maybe we could compare the output of yarn --version and yarnpkg --version to give us a good enough heuristic that they're the same. The downside of any detection like this is that we would have to invoke the Yarn command twice in each script that shows the instructions (init, build, start), slowing down the execution (at the moment we only check if yarn.lock exists). This would affect everyone, but only benefit those who need to use Yarn with the yarnpkg alias.

@Timer
Copy link
Contributor

Timer commented Feb 8, 2017

I think calling yarn is cheap, I'm not sure about spinning up a process tho -- if it was a unix only solution we could do something like:

[ $(yarn --version) == $(yarnpkg --version) ] && echo "yarn" || echo "yarnpkg"

We could have different checks for each OS?

@Timer
Copy link
Contributor

Timer commented Feb 8, 2017

Actually, I'd even argue we stop suggesting yarn for windows users because it's insanely slow vs npm.

@gaearon
Copy link
Contributor

gaearon commented Feb 8, 2017

Is it still slow with the hoisting workaround? I think a lot of slowness is due to duplicate dependencies and the linking phase.

@Timer
Copy link
Contributor

Timer commented Feb 8, 2017

I haven't tried it super recently but the linking stage just takes 200+ seconds, even longer when coupled with anti-virus.

@gaearon
Copy link
Contributor

gaearon commented Feb 8, 2017

I'm fairly sure this is at least partially alleviated by #1441.

@viankakrisna
Copy link
Contributor

Why not just use npm for the list of commands, and detect if the user installed yarn they can use that instead of npm? Something like

We detected that yarn is installed on your system, you can safely replace
npm with yarn or yarnpkg for the commands.

@gaearon
Copy link
Contributor

gaearon commented Feb 24, 2017

We already changed this in README so I think it's good to close.

@gaearon gaearon closed this as completed Feb 24, 2017
@lock lock bot locked and limited conversation to collaborators Jan 22, 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

6 participants