天天看点

vue项目打包后在本地运行

vue项目打包后在本地运行

首先运行命令

npm run build

。运行成功后vue项目中会生成一个dist文件夹。怎样将这个文件夹在本地运行呢?需要如下几个步骤:

1、cd 到dist文件夹中,运行http-server这个命令;

如果出现下面这个错误:

vue项目打包后在本地运行

就找到C盘下C:\Windows\System32\WindowsPowerShell的powershell.exe这个文件并用管理员方式进行运行,点开后输入命令

set-ExecutionPolicy RemoteSigned

,

之后在项目终端中运行

npm install http-server -g

最后运行

http-server

出现如下结果,即可运行打包后的项目在本地浏览。

vue项目打包后在本地运行