4
头图

Compared with Webpack, Vite has the following characteristics

1. Fast cold start, no need to wait for packaging
2. Instant hot module update, real on-demand compilation, no need to wait for the entire project to be compiled

Vite build Vue project

Prerequisite: Install Node.js and Vite

The first step <br>Create a Vite project via npm

 npm init vite-app 项目名称
 # 例如
npm init vite-app HelloVue

The second step <br>When the project is created successfully, cd to the project directory

 cd 项目名称
 # 例如
cd HelloVue

The third step <br>Install project dependencies

 npm install

Step 4 <br>Run the project

 npm run dev

image.png

Some problems that may occur during the build process

 >> npm install 命令很慢或者卡住不动,那是因为npm服务器在境外,必然是很慢的,这边提供两种方案去解决。

【方法一】
https://blog.csdn.net/qq_39595769/article/details/123055196

【方法二】
使用国内镜像(推荐)

(1) 先安装cnpm 
npm install -g cnpm --registry=https://registry.npm.taobao.org

(2) 然后使用cnpm命令
cnpm install

image.png
image.png

 2、npm run dev提示“vite不是内部或外部命令”,可能你还没安装vite,可以输入以下命令进行安装。

image.png

 npm install vite

image.png

After the installation is successful, npm run dev again should be fine.

Author: TANKING
WeChat: sansure2016


TANKING
4.8k 声望493 粉丝

热爱分享,热爱创作,热爱研究。