Coexistence of Vue3+ and Vue2

At present, most new projects will be developed using Vue3+. However, the company still needs to maintain some projects developed using the old version of Vue2. At this time, we need to install vue2 and vue3+ on the computer.

1. First, let’s talk about the parameter -g of the npm installation command

The -g parameter can install the js package globally, that is, install it in the current user directory

For example, use the command

npm install -g @vue/cli
can install the latest version of vue to the user directory, and use where vue to view the directory where the global vue is located

E:>where vue
C:\Users\Administrator\AppData\Roaming\npm\vue
C:\Users\Administrator\AppData\Roaming\npm\vue.cmd
The reason why vue instructions can be used anywhere is because the node is installed The npm environment variable is automatically configured, that is, the directory

C:\Users\Administrator\AppData\Roaming\npm
system can recognize vue commands

2. Install the vue2 version in the specified directory

For example, in the following directory D:\Program Files\vue2

First cd to the D:\Program Files\vue2 directory

Using non-globally installed commands

npm install vue-cli
can install the latest version of vue2 to this directory. At this time, there are more node_modules folders and package.json files in this directory

At this point, you can use vue2 related instructions in the D:\Program Files\vue2\node_modules.bin directory

Note: At present, the vue2 command is invalid after leaving the D:\Program Files\vue2\node_modules.bin directory

3. Configure vue2 environment variables

The effect is that vue2 related instructions can be used in any directory

a. Put the vu in the D:\Program Files\vue2\node_modules.bin directory

Guess you like

Origin blog.csdn.net/zhangzhaoyuxunlei/article/details/105924285