Vue: Install yarn in VSCode and use the yarn tool to control the detailed process of the Vue project

Ⅰ. YarnTool introduction:

1. What is yarna tool:

YarnIt is facebooka resource package management tool released by to replace npm, which is a fast, reliable and safe dependency management tool, and a new JavaScriptresource package management tool (under the spit: the biggest disadvantage is that it needs to be npminstalled through );

2. Advantages of yarncomparison npmtools:

One, npmaspect:

A. npm installVery slow:

In particular, it takes a long time to wait for a new project to be pulled down, and installit will still be the same when it is restarted;

In deletion node_modules, it will not be successfully deleted due to other reasons;

B. The version cannot be kept consistent:

For the same project, the module version cannot be kept consistent during installation, which is due to package.jsonthe version number in the file;

C. The installation error is overwritten:

When installing, the packages will be downloaded and installed at the same time, at some point in the middle, a package throws an error, but npmwill continue to download and install the package;

Second, yarnaspects:

A. Faster installation:

Offline cache, yarnwhich caches each downloaded package, so there is no need to download it again when it is used again;

Also utilizes parallel downloads to maximize resource utilization, so installs are faster.

B. The installation version is the same:

Before the code is executed, Yarnthe integrity of each installation package is verified by an algorithm;

And in order to prevent pulling different versions, Yarnthere is a lock file (lock file)that records the version number of the module that is exactly installed;

C. Concise semantics:

yarnChanged some npm 命令names, e.g. yarn add/remove, to be clearer than npmthe original ;install/uninstall

3. Reasons for wanting to download and use the yarnmanagement vueproject:

First, because when using npmthe tool to manage vuethe project, an error ( 但错误原因没找到) is reported:

npm ERR! ENOTEMPTY: directory not empty, rename '/usr/local/lib/node_modules/webpack' -> '/usr/local/lib/node_modules/.webpack-ENG41nb9'

// The overall code of the error is:

npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/webpack
npm ERR! dest /usr/local/lib/node_modules/.webpack-ENG41nb9
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/usr/local/lib/node_modules/webpack' -> '/usr/local/lib/node_modules/.webpack-ENG41nb9'

npm ERR! A complete log of this run can be found in:

Second, when using yarnthe tool to manage vuethe project, no error is reported;

Ⅱ. Steps to Vueinstall in the project Yarn:

1. yarnThe command to install:

npm install -g yarn

2. VSCodeCheck yarnthe version in: 报错

If there is an error, please continue to read in order, if there is no error, just skip 3、to read;

First, the error message is:

yarn 无法加载文件 “C:\Users\admin\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本

Second, the overall error message is:

insert image description here

Third, but in cmdthe command, no error is reported:

insert image description here

Fourth, the solution to this problem is:

// Please see the article at this address:

https://blog.csdn.net/weixin_43405300/article/details/131533816?spm=1001.2014.3001.5501

3. VSCodeCheck yarnthe version in: 未报错

First, yarnthere is no problem viewing the version:

In the VScode environment, enter the command: yarn --version, the displayed result is:1.22.19

insert image description here

Second, but at this time, if you enter yarn run servethe command directly, it will have no effect:

insert image description here

4. Execute the command:yarn install

insert image description here

5. Execute the command:yarn run serve

// At this point, it has successfully run, and there is no problem with access;

insert image description here

Ⅲ. Summary:

First, where there is something wrong or inappropriate, please give me some pointers and exchanges!
Second, if you are interested, you can pay more attention to this column (Vue (Vue2+Vue3) interview must-have column):https://blog.csdn.net/weixin_43405300/category_11525646.html?spm=1001.2014.3001.5482

Guess you like

Origin blog.csdn.net/weixin_43405300/article/details/131533642