How to install all the dependency package in yarn?

15,493

Solution 1

You should just be able to run yarn install

Here is a comparison table of most/all the commands you'd likely encounter


Edit Sept 2020: The newer versions of npm have greatly improved and caught up to yarn, so I currently have no clue what possible benefits yarn offers anymore, I'm 100% npm for the last year or so

Solution 2

The equivalent of $ npm install is just $ yarn (without arguments) to install all dependencies from package.json.

Also, just to clarify your query -

Just found that it has only package.json, which means I can only use npm install to install dependencies. Would there be no problem when I use yarn later?

Doesn't matter whether you use yarn or npm, there will always be a package.json.

And no, there won't be a problem when using yarn later.

You get package-lock.json when using npm, and yarn.lock file when using yarn. It's not recommended to use both yarn and npm for the same project, so you should remove either of package-lock.json and yarn.lock.

Share:
15,493
Jay P.
Author by

Jay P.

Updated on June 12, 2022

Comments

  • Jay P.
    Jay P. almost 2 years

    First, I'm new to React. I'm trying to use Google's Material-UI for my React project. In this tutorial, it says run npm install, but I heard using yarn and npm together in the same project because it might bring about some confusion between those two later. So, I'm trying to stick to yarn only.

    npm install seems to install all the dependency package for the thing that I wanna use, but how can I do that in yarn? I tried yarn add, but it didn't work. How can I do that?

    EDIT

    Just found that it has only package.json, which means I can only use npm install to install dependencies. Would there be no problem when I use yarn later?

  • Jay P.
    Jay P. over 5 years
    that link gives me a big help! Thanks a lot
  • robvelor
    robvelor over 2 years
    @Thymine Yarn still edges out npm because it supports simultaneous package installs.