In the blog post announcing yarn (an alternative npm client) they say, "The easiest way to get started is to run npm install -g yarn
". But if you go to the "install yarn" page in their docs, "npm install yarn" isn't listed on any of the platform-specific installation pages, and it's only offered as the third of three options on the "Alternatives" page. Furthermore when you npm install
yarn it prints a deprecation warning, "It is recommended to install Yarn using the native installation method for your environment." So my question is if npm install
is the easiest installation method, why isn't it a recommended method in their docs? Are there disadvantages to installing yarn using npm
?
相关问题
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- google-drive can't get push notifications
- Failed at the electron@1.8.2 postinstall script
- How to reimport module with ES6 import
- Webpack getting started, import error
相关文章
- node连接远程oracle报错
- How can make folder with Firebase Cloud Functions
- @angular-cli install fails with deprecated request
- node.js modify file data stream?
- How to resolve hostname to an ip address in node j
- Transactionally writing files in Node.js
- Log to node console or debug during webpack build
- Get file created date in node
There's no visible disadvantage to installing Yarn through
npm
. In fact I chose this method myself because of a few reasons:npm i --global yarn
and you can literally replacenpm
withyarn
on your console immediately.nvm
and maintaining different code projects on each NodeJS version, then you can install Yarn on one version and not have it on the otherBecause
npm
is not platform specific and runs on almost any system it is listed as an Alternative. There is no advantage or disadvantage over the platform specific installs. The difference would be the install location but all methods expose the globalyarn
command to your CLI.I would argue they listed it as "the easiest way" because most people are already very familiar with
npm
.According to the Yarn project maintainers, installing Yarn via npm goes against the goals of the project, can cause issues, and is, in general, worse than platform-specific installation methods.
Advantages to recommended platform-specific installation:
The Yarn teams regards npm as insecure and unreliable. From the "Install via npm" section on Yarn's "Installation" page:
Running Yarn, which is a separate package manager utility, via npm can lead to edge-case issues (see issue 2072)
Advantages to
npm install -g yarn
:npm install -g yarn
)npm update -g yarn
)yarn self-update
) but it seems to be brokennvm
The system package manager arguments for the recommended installation tend to break down when referring to Windows, where there is no official package manager (unless you count Windows Update). Also, Windows package managers such as Chocolatey are often not configured for automatic updates.
I'm not sure that I fully agree with the Yarn team's decision on this, but they do make some fair points. The Yarn project is still young and if it is to become a replacement for npm then it wouldn't make sense to encourage npm as its primary installer.
Regardless, installations via npm seem to work just fine for now in most cases.
Sources: