Yarn: A JavaScript Package Manager

Jamison Dance
InstructorJamison Dance
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 5 years ago

Yarn is a new JavaScript package manager that aims to be speedy, deterministic, and secure. See how easy it is to drop yarn in where you were using npm before, and get faster, more reliable installs.

[00:01] Yarn is a package manager for JavaScript. We can install it with the other package manager for JavaScript by typing, "npm install -g yarn." I've checked out the React source code. Let's use Yarn to install its dependencies. We can do that just by typing, "yarn."

[00:19] It reads from the package.json file, so it should work on any project that's already using npm. It's pretty speedy too. It took about 12 seconds. With npm, it took almost two minutes. It puts its dependencies in Node modules, just like npm, so all your tooling should work the same.

[00:36] Let's check out the getStatus to see what changed. Yarn added this yarn.lock file. What's that about? The yarn.lock file lists every dependency and the exact version of that dependency that was installed. This is what lets Yarn be reproducible and deterministic.

[00:54] When Yarn installs from a yarn.lock file, it installs the exact same code everywhere. Let's add this to source control, so that our team can get the same dependencies that we have.

[01:03] You know what React really needs is Backbone.js. Let's use Yarn to add Backbone, as a dependency, to React. We can do that by typing, "yarn add backbone." Let's check out the getStatus to see what has changed.

[01:29] You can see that two files were modified, package.json and yarn.lock. Backbone was added as a dependency in package.json. Backbone and Underscore were both added to the yarn.lock file. That's because Backbone depends on Underscore.

[01:44] Every dependency and all of the dependency's dependencies get added to the yarn.lock file. Let's commit this. Finish React. It's now complete.

yulia
yulia
~ 6 years ago

Hi I have one remark. You said, "React really needs Backbone". Probably, do you wanna say "babel"? Don't you? or something else?

Helmer Davila
Helmer Davila
~ 6 years ago

Hi I have one remark. You said, "React really needs Backbone". Probably, do you wanna say "babel"? Don't you? or something else?

I heard the same. Is babel js i think

Markdown supported.
Become a member to join the discussionEnroll Today