- Yarn introduction
- Install yarn
- Management Pack
- Check the license
- Check dependencies
- Upgrade package
- How to upgrade yarn
it isCompatible with npm packages, So it has a huge advantage to replace npm.
It starts up much faster than before
npmDue to parallel downloading and caching, but now
npmIt has indeed caught up with many of its features, and it is now my recommended solution.
Tools will eventually merge into a set of features to keep them at the same level to maintain relevance, so we may see these features in npm in the future-competition is good for our users.
Although you can install Yarn bynpm(
npm install -g yarn), the Yarn team does not recommend this.
The system-specific installation methods are listed in the following locationshttps://yarnpkg.com/zh-CN/docs/install. For example, on macOS, you can useHouse wineAnd run
brew install yarn
But each operating system has its own package manager of choice, which can make the process very smooth.
Finally, you will get
yarnCommands available in Shell:
Yarn writes its dependencies to a file named
package.json, Which is located in the root folder of the project, and stores the dependency file to
node_modulesfolder,Just likenpmIf you have used it in the past.
Initialize a new project
Start an interactive prompt to help you quickly start a project:
Install the dependencies of an existing project
If you already have one
package.jsonFile containing a list of dependencies, but the package has not been installed yet, please run
Start the installation process.
Install the package locally
Use the following command to install the package into the project
yarn add package-name
Install packages globally
yarn global add package-name
Install the package locally as a development dependency
yarn add --dev package-name
--save-devMark in npm
Take out the package
yarn remove package-name
Check the license
When installing many dependencies, these dependencies may have many dependencies. You will install many packages without knowing anything about the license used by these packages.
Yarn provides a convenient tool to print the licenses of any dependencies you have:
yarn licenses ls
And it can also automatically generate a disclaimer, includingAllLicense for the project you are using:
yarn licenses generate-disclaimer
Have you checked
node_modulesFolder, want to know why a particular package is installed?
yarn whyTell you:
yarn why package-name
If you want to upgrade a single package, run
yarn upgrade package-name
To upgrade all packages, run
But this command can sometimes cause problems because you are blindly upgrading all dependencies without worrying about major version changes.
Yarn has a good tool to selectively update the packages in the project, which is of great help in this situation:
How to upgrade yarn
At the time of writing, there is no automatic update command.
If you have used
brewInstall as suggested above, please use:
brew upgrade yarn
If you installed using npm, please use:
npm uninstall yarn -g npm install yarn -g
More devtools tutorials:
- Yoman Introduction
- Bower, browser package manager
- Introduction to front-end testing
- Use node-webkit to create desktop applications
- VS Code: Use language-specific settings
- Introduction to Webpack
- A short and concise guide to the Tower of Babel
- Yarn introduction
- Overview of Browser DevTools
- Use Prettier to format code
- Use ESLint to keep your code clean
- List of cool Chrome DevTools tips and tricks
- How to use Visual Studio Code
- Introduction to Electronics
- Package, simpler Webpack
- Emmet's HTML reference
- Configure VS Code
- Configure macOS command line
- How to disable ESLint rules
- How to open VS Code from the command line
- How to set up hot reinstallation on Electron