Home >Web Front-end >Front-end Q&A >Yarn installation nodejs tutorial
Yarn is a fast, reliable, and secure dependency management tool that has become one of the indispensable tools in web development. When developing with yarn, installing Node.js is an inevitable step. Below I will introduce you to the yarn tutorial for installing Node.js.
First, we need to download it from the yarn official website (https://classic.yarnpkg.com/en/docs/install/#mac-stable) and install yarn. In the download page, we can choose the corresponding version according to our operating system.
The npm warehouse used by yarn by default is relatively slow to access in China, but we can increase the download speed of the package by configuring the mirror. Execute the following command to configure the Taobao image:
yarn config set registry https://registry.npm.taobao.org/
Before installing Node.js, we need to determine whether Node.js already exists on the current system , and its version. We can check the Node.js version by entering the following command in the command line terminal:
node -v
If Node.js is already installed on the system, the installed version number will be displayed. If it is not installed, you need to install Node.js.
There are many ways to install Node.js, such as downloading the installation package through the official website, through package managers (such as Homebrew, yum and apt -get, etc.) for installation, etc. In this article, we use brew to install Node.js on Mac as an example:
First install brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Then install Node.js:
brew install node
After executing the above command, wait for the installation to complete.
After the installation is completed, we need to check again whether Node.js and yarn are installed successfully. We can enter the following command in the command line terminal to check the Node.js version and yarn version:
node -v yarn -v
If the corresponding version number is displayed, it means that Node.js and yarn have been successfully installed.
Summary:
Through the above steps, we can successfully use yarn to manage dependencies on Node.js. When doing web development, yarn can help us better manage front-end code and improve development efficiency and program performance.
The above is the detailed content of Yarn installation nodejs tutorial. For more information, please follow other related articles on the PHP Chinese website!