本文共 4164 字,大约阅读时间需要 13 分钟。
hadoop纱线集群是什么
Yarn is a Package Manager, a direct competitor of , and it’s one of the Facebook Open Source projects.
Yarn是 Package Manager,是的直接竞争对手,并且是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中看到这些功能-竞争对我们用户来说很好。
While you can install Yarn with (npm install -g yarn
), it’s not recommended by the Yarn team.
虽然可以使用 ( npm install -g yarn
)安装Yarn,但是Yarn团队不建议这样做。
System-specific installation methods are listed at . On macOS for example you can use Homebrew and run
特定于系统的安装方法列在 。 例如,在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 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 if you used it in the past.
Yarn将其依赖项写入名为package.json
的文件中,该文件位于项目的根文件夹中,并将依赖项文件存储到node_modules
文件夹中, 就像过去使用一样。
yarn init
starts an interactive prompt that helps you quick start a 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.
开始安装过程。
Installing a package into a project is done using
使用以下命令将软件包安装到项目中
yarn add package-name
yarn global add package-name
yarn add --dev package-name
Equivalent to the
--save-dev
flag in npm等效于npm中的
--save-dev
标志
yarn remove package-name
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
and it can also generate a disclaimer automatically including all the licenses of the projects you use:
并且它还可以自动生成免责声明,包括您使用的项目的所有许可证:
yarn licenses generate-disclaimer
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
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
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 -gnpm install yarn -g
翻译自:
hadoop纱线集群是什么
转载地址:http://beqgb.baihongyu.com/