hadoop纱线集群是什么_纱线介绍

hadoop纱线集群是什么

纱线介绍 (Intro to Yarn)

Yarn is a JavaScript Package Manager, a direct competitor of npm, and it’s one of the Facebook Open Source projects.

Yarn是JavaScript Package Manager,是npm的直接竞争对手,并且是Facebook开放源代码项目之一。

It’s compatible with npm packages, so it has the great advantage of being a drop-in replacement for npm.

与npm软件包兼容 ,因此具有取代npm的巨大优势。

When it launched it used to be way faster than npm due to parallel download and caching, but now npm did catch up with many of its features and is now the solution I recommend.

当它启动时,由于并行下载和缓存,它的速度通常比npm快,但是现在npm确实赶上了它的许多功能,现在是我推荐的解决方案。

Tools eventually converge to a set of features that keeps them on the same level to stay relevant, so we’ll likely see those features in npm in the future - competition is nice for us users.

工具最终会融合为一组功能,使它们保持相同的水平以保持相关性,因此我们将来可能会在npm中看到这些功能-竞争对我们用户来说很好。

安装纱 (Install Yarn)

While you can install Yarn with npm (npm install -g yarn), it’s not recommended by the Yarn team.

虽然可以使用npm ( npm install -g yarn )安装Yarn,但是Yarn团队不建议这样做。

System-specific installation methods are listed at https://yarnpkg.com/en/docs/install. On macOS for example you can use Homebrew and run

特定于系统的安装方法列在https://yarnpkg.com/en/docs/install 。 例如,在macOS上,您可以使用Homebrew并运行

brew install yarn

but every Operating System has its own package manager of choice that will make the process very smooth.

但是每个操作系统都有自己选择的软件包管理器,可以使过程非常顺利。

In the end, you’ll end up with the yarn command available in your shell:

最后,您将获得shell中可用的yarn命令:

Yarn command installed

管理包 (Managing packages)

Yarn writes its dependencies to a file named package.json, which sits in the root folder of your project, and stores the dependencies files into the node_modules folder, just like npm if you used it in the past.

Yarn将其依赖项写入名为package.json的文件中,该文件位于项目的根文件夹中,并将依赖项文件存储到node_modules文件夹中, 就像过去使用npm一样。

初始化一个新项目 (Initialize a new project)

yarn init

starts an interactive prompt that helps you quick start a project:

启动一个交互式提示,可帮助您快速启动项目:

Running yarn init

安装现有项目的依赖项 (Install the dependencies of an existing project)

If you already have a package.json file with the list of dependencies but the packages have not been installed yet, run

如果您已经具有带有依赖项列表的package.json文件,但是尚未安装软件包,请运行

yarn

or

要么

yarn install

to start the installation process.

开始安装过程。

在本地安装软件包 (Install a package locally)

Installing a package into a project is done using

使用以下命令将软件包安装到项目中

yarn add package-name

全局安装软件包 (Install a package globally)

yarn global add package-name

在本地安装软件包作为开发依赖项 (Install a package locally as a development dependency)

yarn add --dev package-name

Equivalent to the --save-dev flag in npm

等效于npm中的--save-dev标志

取出包裹 (Remove a package)

yarn remove package-name

检查许可证 (Inspecting licenses)

When installing many dependencies, which in turn might have lots of dependencies, you install a number of packages, of which you don’t have any idea about the license they use.

当安装许多依赖关系时,这些依赖关系又可能具有很多依赖关系,您将安装许多软件包,而对于它们使用的许可证一无所知。

Yarn provides a handy tool that prints the license of any dependency you have:

Yarn提供了一个方便的工具,可以打印您具有的任何依赖项的许可证:

yarn licenses ls

The yarn packages licenses visualized

and it can also generate a disclaimer automatically including all the licenses of the projects you use:

并且它还可以自动生成免责声明,包括您使用的项目的所有许可证:

yarn licenses generate-disclaimer

Disclaimer generated by yarn

检查依赖 (Inspecting dependencies)

Do you ever check the node_modules folder and wonder why a specific package was installed? yarn why tells you:

您是否曾经检查过node_modules文件夹,并且想知道为什么安装了特定的软件包? yarn why告诉你:

yarn why package-name

The result of yarn why

升级包 (Upgrading packages)

If you want to upgrade a single package, run

如果要升级单个软件包,请运行

yarn upgrade package-name

To upgrade all your packages, run

要升级所有软件包,请运行

yarn upgrade

But this command can sometimes lead to problems, because you’re blindly upgrading all the dependencies without worrying about major version changes.

但是此命令有时会导致问题,因为您是在盲目升级所有依赖项而不必担心主要版本更改。

Yarn has a great tool to selectively update packages in your project, which is a huge help for this scenario:

Yarn有一个很好的工具可以有选择地更新项目中的程序包,对于这种情况有很大的帮助:

yarn upgrade-interactive

Upgrading packages with yarn

如何升级纱线 (How to upgrade Yarn)

At the time of writing there is no auto-update command.

在撰写本文时,没有自动更新命令。

If you used brew to install it, like suggested above, use:

如果您像上面建议的那样使用brew安装,请使用:

brew upgrade yarn

If instead you installed using npm, use:

如果您是使用npm安装的,请使用:

npm uninstall yarn -g
npm install yarn -g

翻译自: https://flaviocopes.com/yarn/

hadoop纱线集群是什么

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值