技术控

    今日:150| 主题:49194
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] So I tried Yarn, yet another new JavaScript tool

[复制链接]
扯不掉的面具 发表于 2016-10-20 01:16:59
132 3

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

So I tried Yarn, yet another new JavaScript tool-1 (framework,Facebook,presented,developer,developed)
        Recently Yarn  (the new JavaScript package manager developed by engineers at Facebook, Google and Tilde) emerged as an alternative to npm .
   The main argument for me to give it a try was that it was presented as fast (first word on the website and the GitHub )  and it seems to be , I always found npm slow, maybe that’s because I am also a Spring developer using Maven and I’m tired of drinking my coffee while looking at the dependencies being downloaded before I can make a Hello World with my favorite oversized framework.
  Repetitive tasks like downloading dependencies, building, linting, runing tests, … need to be the fastest possible, and trying Yarn follows that logic.
  To every JavaScript developer thinking as I did “A new tool.. again… yay !”, don’t worry, it’s actually pretty straightforward, it’s just another package manager, you know how it works, so basically all you need is to know how to init a project, add dependencies, download them, and you’re good to go.
  How to install Yarn

   Personnally, I installed it through npm but they have a lot of possibilities in their installation guide .
  [code]$ npm install -g yarn$ yarn --version # should give 0.16.1 at the time of writing[/code]  How to init a project

  [code]$ yarn init[/code]   You’ll have to answer a few question exactly like npm does with npm init , and it will create the package.json file for you, nothing new, moving on.
  For the name of your project, npm only allows URL-friendly characters (no spaces, …), Yarn doesn’t complain, BUT will error when you’ll try to add a dependency.
  How to add a dependency

  [code]$ yarn add angular # for the latest version$ yarn add [email protected][/code]  # for a specific version
  $ yarn add --dev gulp # dev dependency
   Same as npm, the node_modules directory is created and angular is added.
  (If you install Angular 1.5.1 and then Angular 1.5.8, only the 1.5.8 will be available, there is only one version of a package at a time).
  How to upgrade a dependency

  [code]$ yarn upgrade angular[/code]  How to remove a dependency

  [code]$ yarn remove angular[/code]  How to download all dependencies

  [code]$ yarn install[/code]  [code]or[/code]  [code]$ yarn[/code]  As you can see, it’s the same as npm so far, a few differences :
  [code]npm install => yarn addnpm install --save dev => yarn add --dev[/code]   Yarn also has an offline mode with the --offline switch, it will look up the local registry and take the dependencies from here if it’s been already downloaded, a little feature that can come in handy.
  Conclusion

  I’m using Yarn in my new side project, and so far I like how fast it is, it’s not less easy than npm to use, thus until it proves me wrong, I’ll keep using it over npm. In my opinion, if someone tells you about Yarn, yet another JavaScript tool, don’t yawn, Yarn :)
友荐云推荐




上一篇:Semi-hosting on ARM with Rust
下一篇:A new ecosystem for Haskell: the JVM
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

问夏 发表于 2016-10-24 03:21:48
报告!别开枪,我就是路过来看看的。。。
回复 支持 反对

使用道具 举报

修洁 发表于 2016-10-26 23:18:04
前排卖瓜子,汽水!
回复 支持 反对

使用道具 举报

问夏 发表于 2016-11-21 06:46:44
远看是美景,近看想报警。
回复 支持 反对

使用道具 举报

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表