• Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

I heard before that Vite is a word fast, but I have not studied it. Just recently, Vite has been upgraded to 2.0, which is relatively stable and has time, so I specially came to study vite and record the problems encountered.

1. Introduction of Vite

Vite, a development server based on browser native ES Imports. Parsing the imports in the browser, compiling and returning them on the server side on demand, bypassing the concept of packaging entirely, and making the server available on demand. Not only does it have Vue file support, it also handles hot updates, and the speed of hot updates does not slow down with the increase of modules. The main features of Vite are: 1. Fast cold start 2. Timely module hot update 3. True on-demand compilation

2. Vite installation

Use NPM:

npm init @vitejs/app
Copy the code

Using Yarn:

yarn create @vitejs/app
Copy the code

Then follow the prompts to operate! You can also directly specify the project name and the template you want to use through additional command-line options. For example, to build a Vite + Vue project, run:

# NPM 6. X NPM init @vitejs/app my-vue-app --template vue # NPM 7+  npm init @vitejs/app my-vue-app -- --template vue # yarn yarn create @vitejs/app my-vue-app --template vueCopy the code

Most of them are installed correctly, but unfortunately I’m in that minority. C:\Program Files are not internal or external commands, nor are they runnable programs or batch Files. However, no matter how to modify the node version or delete the node and reinstall it, it is found that the node installation file name Program Files has a space. 1. Run the NPM config get cache command to view nodeJS path 2. Run NPM config set cache “C: Program~1\nodejs” –global to change path 3. 4. Then run NPM install and NPM run dev in the project file to start project 5. Then you have a feeling that it is really fast, and modify the file hot start can still preserve the state, the experience is really great

Vite project development in subsequent articles, if interested can move to vite trivia (2) oh.