Skip to content

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

Closed

Description

@benjaminapetersen

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.

Activity

  1. ro-savage commented on Feb 8, 2017

    @ro-savage
    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.

  2. benjaminapetersen commented on Feb 8, 2017

    @benjaminapetersen
    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.

  3. gaearon commented on Feb 8, 2017

    @gaearon
    Contributor

    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?

  4. changed the title [-]README.md file needs some updates![/-] [+]README uses npm commands, but the tool suggests to use yarn[/+] on Feb 8, 2017
  5. gaearon commented on Feb 8, 2017

    @gaearon
    Contributor

    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

  6. fson commented on Feb 8, 2017

    @fson
    Contributor

    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.

  7. Timer commented on Feb 8, 2017

    @Timer
    Contributor

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

  8. fson commented on Feb 8, 2017

    @fson
    Contributor

    @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.

  9. Timer commented on Feb 8, 2017

    @Timer
    Contributor

    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?

  10. Timer commented on Feb 8, 2017

    @Timer
    Contributor

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

  11. gaearon commented on Feb 8, 2017

    @gaearon
    Contributor

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

  12. Timer commented on Feb 8, 2017

    @Timer
    Contributor

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

  13. gaearon commented on Feb 8, 2017

    @gaearon
    Contributor

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

  14. viankakrisna commented on Feb 22, 2017

    @viankakrisna
    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.
    
  15. gaearon commented on Feb 24, 2017

    @gaearon
    Contributor

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

  16. locked and limited conversation to collaborators on Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions