Installation and environment configuration of yarn tool on win10 platform

    Yarn is a new JS package management tool jointly launched by Facebook, Google, Exponent, and Tilde . As written in the official document, Yarn appeared to make up for some of the defects of npm. Like npm, yarn can be used to add and delete a certain package, but yarn is faster than npm to install packages, and the installation syntax is more concise.
    The command comparison is as follows:

npm install  <==> yarn 
npm install taco --save <==> yarn add taco
npm uninstall taco --save <==> yarn remove taco
npm install taco --save-dev <==> yarn add taco --dev
npm update --save <==> yarn upgrade

    The following describes the installation and environment configuration of the yarn tool on the win10 platform.
    1. Use the PowerShell administrator to install the yarn tool
    1.1 Press Win+R, enter: powershell -> Enter, the first blue PowerShell pops up, and enter the command inside:

Start-Process powershell -Verb runAs 

    1.2 In the second blue box that pops up , continue to enter the following commands:

   set-ExecutionPolicy RemoteSigned
   A

    1.3 Enter the global installation command of yarn:

npm install -g yarn

    2. Configure yarn environment variables.
    Here, take the default path of node, namely C:\Program Files as an example. Of course, if your node is installed on another disk, just change it to the actual path of node .
    2.1 In the system environment variables, add a NODE_PATH variable, as follows:
    Click [My Computer] -->Properties --> Advanced System Variables -->Environment Variables --> System Variables --> New:
    Variable Name: NODE_PATH
    Path: C:\Program Files\nodejs\node_global\node_modules;

Figure (1) Add NODE_PATH system variable

    2.2 At the same time, add the C:\Program Files\nodejs\node_global\node_modules path above to the Path of [User Variables], as shown in Figure (2):

Figure (2) Add a copy of the same path to the user variable Path

    2.3 Set the global installation directory and cache directory of the node software package. In the blue box of the powershell administrator, enter the following two commands:

npm config set prefix "C:\Program Files\nodejs\node_global"
npm config set cache "C:\Program Files\nodejs\node_cache"

    3. Restart the computer
    4. Enter the blue box of powershell and enter the following command:

yarn -v

    If the version information is printed, it indicates that the yarn environment variable is set successfully, that is, the yarn command can be recognized by the system. As shown in Figure 3:

Figure (3) The version information of yarn can be printed, which means that the environment configuration is successful

Guess you like

Origin blog.csdn.net/sanqima/article/details/108807898